/* ALL DESIGN TOKENS LIVE IN design-tokens.css (one shared file for this app AND Forward
   Inventory, added 2026-08-27 per the owner - 'one shared stylesheet so it never drifts').
   Every page loads it BEFORE this file. Never declare a --token value in this file again:
   colors, font sizes, spacing, radii, shadows, and BOTH dark palettes are defined there
   once, for both apps. This file is components only. */
/* Palette remapped 2026-08-24 to follow Forward Inventory's design (forwardfurnitureinventory.
   vercel.app), per explicit user request - was near-black + amber/Roboto pulled from
   forwardfurniture.ca, now inventory's blue accent + system-ui + inventory's exact status hues.
   Every variable NAME below is unchanged on purpose: the ~1400 lines beneath this block, and
   every inline color reference in the HTML/JS, already key off these names - remapping what
   they POINT TO (instead of touching every rule that consumes them) is what makes this a
   contained edit instead of a rewrite. --ink is used both as body text color AND as the
   background for dark/inverse elements (group-row headers, toasts) - inventory's own --ink
   serves the same dual role, so the mapping carries over directly. Layout (top nav, not
   inventory's sidebar) deliberately NOT changed - see the chat thread for why. */


* { box-sizing: border-box; }

body {
  margin: 0;
  /* 2026-08-27: full font parity with Forward Inventory - Inter webfont (loaded per-page
     from Google Fonts) with the cv11 single-storey-a cut, system stack as fallback. */
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: 'cv11';
  background: var(--bg);
  color: var(--text);
  /* The 0.2px letter-spacing was part of the amber/Roboto brand identity this file used to
     carry; inventory's type doesn't use it, so it's dropped for a plainer, tighter read. */
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --app-pad had no desktop value (only the <=1200px media queries set it), so above 1200px every
   page's content ran flush against the sidebar and pages that noticed added their own 24px
   wrappers, which is why some tabs sat further in than others. 24px is the one desktop gutter
   now, stepping down to 20/18/14/12 in the responsive layer below (2026-09-18). */
:root { --app-pad: 24px; }
.app { max-width: none; width: 100%; margin: 0; padding: var(--app-pad); }

/* Visible keyboard focus. The only focus treatment in this file used to be
   `input:focus { outline: none; border-color: accent }`, which removed the focus ring
   outright for keyboard users on every control in the app and left buttons and links with
   nothing at all. :focus-visible keeps the ring off for mouse clicks, so the polish of the
   original is preserved while the app becomes keyboard-navigable. */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--r-sm);
  position: relative;
  z-index: 4;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
  /* Freeze the header/nav at the top while the page scrolls. --topbar-h is measured live by
     nav-reports-link.js so the sticky table column-headers (th, below) sit just under it. The
     negative top + matching padding-top pull the bar flush to the very top of the viewport,
     cancelling the .app padding so nothing peeks above it. Both now read from --app-pad so
     that when the page padding shrinks at a breakpoint the pull-up stays exactly matched -
     hard-coding 24px here meant a narrower page would either gap or clip at the very top. */
  position: sticky;
  top: -1px;
  z-index: 30;
  background: var(--bg);
  padding-top: var(--app-pad);
  margin-top: calc(var(--app-pad) * -1);
  /* Lifts the bar off the content scrolling under it. The plain 1px border alone let dense
     table rows read as if they were part of the header once they scrolled beneath it. */
  box-shadow: var(--shadow-header);
}
@supports (backdrop-filter: blur(8px)) or (-webkit-backdrop-filter: blur(8px)) {
  .topbar {
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(180%) blur(10px);
    backdrop-filter: saturate(180%) blur(10px);
  }
}
.topbar h1 { font-size: var(--fs-lg); margin: 0; font-weight: 500; color: var(--text-dim); }

/* Brand + nav cluster. Previously an inline flex style on the wrapping <div>; promoted to a
   class so the header can restructure at a breakpoint (the inline rule could not be
   overridden by a media query). The :first-child fallback keeps the layout correct on any
   page whose markup still carries the old inline style. */
.topbar-left,
.topbar > div:first-child:not(.topbar-actions) {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  min-width: 0;      /* lets the nav shrink and scroll instead of forcing the header wider */
  flex: 1 1 auto;
}

/* margin-left:auto keeps this pinned to the top-right corner even when .topbar wraps to a
   second row on narrow viewports - without it, a wrapped topbar-actions block falls back to
   the row's default left edge instead of staying at the right. */
.topbar-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; margin-left: auto; }

.brand {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: 1.05;
  font-weight: 700;
  font-size: var(--fs-sm);
  letter-spacing: 1.6px;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  /* The wordmark was being squeezed and visually clipped ("RD ... RE") once the nav and the
     action buttons competed for the same row. It is the anchor of the whole header, so it is
     now the one thing that never shrinks. */
  flex: 0 0 auto;
  padding-left: 10px;
  border-left: 3px solid var(--accent);
  transition: opacity var(--ease);
}
/* Only fade when the wordmark is actually a link. It stopped being one on 2026-08-17: it pointed
   at the retired Order Status page, so it is now a plain <span> on every internal page and a
   hover effect there would advertise a click that does nothing. product-guides.html and
   track-order.html still link it to forwardfurniture.ca and keep the effect. */
a.brand:hover { opacity: 0.72; }
.brand span { font-size: var(--fs-2xs, 11px); font-weight: 400; letter-spacing: 3px; color: var(--text-dim); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  padding: 9px 16px;
  border-radius: var(--r-md);
  cursor: pointer;
  font-size: var(--fs-sm);
  font-weight: 500;
  font-family: inherit;
  line-height: 1.2;
  white-space: nowrap;
  /* Keeps every control on a single comfortable tap/click height regardless of whether it
     contains a count badge, an emoji glyph or plain text - the header buttons previously
     rendered at three slightly different heights next to each other. */
  min-height: 36px;
  box-shadow: var(--shadow-sm);
  transition: border-color var(--ease), background var(--ease), color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.btn:hover { border-color: var(--border-strong); background: var(--panel); color: var(--ink); }
.btn:active { transform: translateY(1px); box-shadow: none; }
/* Primary changed from ink/black to the accent blue (2026-08-24) - matches inventory's
   .btn.primary exactly, which uses the accent color for its one primary action per screen
   rather than pure black. */
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; font-weight: 700; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #ffffff; }
.btn-ghost { background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--panel-2); }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); box-shadow: none; }
.btn-danger:hover { background: var(--crit-soft, #fceaea); border-color: var(--red); }
.btn[disabled], .btn:disabled { opacity: 0.5; cursor: not-allowed; }

.msg-tab { border-radius: 0; border: none; border-bottom: 2px solid transparent; padding-bottom: 8px; }
.msg-tab.active { border-bottom-color: var(--accent); font-weight: 600; }

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 20px;
}
/* Pins the summary tiles just under the (already-sticky) topbar so they stay visible while
   scrolling a long table below - --topbar-h is measured live per-page (see invoices-app.js)
   since the topbar's real height can vary (nav wrapping, etc.), not just the :root fallback. */
.summary.sticky-summary {
  position: sticky;
  top: var(--topbar-h);
  z-index: 20;
  background: var(--bg);
  /* Cancels .topbar's margin-bottom:20px (they'd otherwise collapse into a visible gap only
     at the very top of the page, before scrolling triggers the sticky top offset - once stuck,
     the gap already closes on its own, so this just makes the un-scrolled state match it). */
  margin-top: -20px;
  padding-top: 8px;
  padding-bottom: 4px;
}
/* Pins the small 3PL x product matrix right below the sticky summary tiles - --sticky-matrix-top
   is measured live (topbar height + summary height) since both vary. z-index below .summary's
   so the summary tiles' own shadow/border still reads as "in front" while both are stuck. */
.table-wrap.sticky-matrix {
  position: sticky;
  top: var(--sticky-matrix-top, var(--topbar-h));
  z-index: 15;
  /* Same margin-collapse cancellation as .sticky-summary, against .summary's margin-bottom:20px. */
  margin-top: -20px;
}
/* Pins the search/filter toolbar (incl. the Status dropdown) right below the sticky matrix -
   --sticky-toolbar-top is measured live (topbar + summary + matrix heights), same reasoning
   as the two rules above. Needs its own background since .toolbar has none by default. */
.toolbar.sticky-toolbar {
  position: sticky;
  top: var(--sticky-toolbar-top, var(--topbar-h));
  z-index: 14;
  background: var(--bg);
  /* Cancels #matrixWrap's inline margin-bottom:20px (same collapse pattern as the two rules above). */
  margin-top: -20px;
  padding-top: 6px;
  padding-bottom: 6px;
}
/* Cancels .sticky-toolbar's own margin-bottom:14px so the invoices table's now page-sticky
   header (#invoicesTable thead th, via --sticky-table-top) sits flush under it at rest too. */
#invoicesTableWrap { margin-top: -14px; }
.summary-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 14px 16px;
  /* The status colour was carried only by the 1px border, which on a pale panel was almost
     invisible at a glance. A 3px left rule states the same thing without shouting, and
     matches the .ins-kpi-card language already used elsewhere in the app. */
  border-left: 3px solid var(--border-strong);
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.summary-card .num {
  font-size: var(--fs-2xl);
  font-weight: 700;
  color: var(--ink);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.summary-card .label {
  font-size: var(--fs-2xs);
  color: var(--text-dim);
  margin-top: 3px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  font-weight: 500;
}
.summary-card.clickable { cursor: pointer; }
.summary-card.clickable:hover {
  border-color: var(--accent);
  border-left-color: var(--accent);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.summary-card.overdue { border-color: var(--red); border-left-color: var(--red); }
.summary-card.overdue .num { color: var(--red); }

/* Filter bar. Given its own surface so it reads as the control strip belonging to the table
   directly beneath it, rather than as loose controls floating on the page background. */
.toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  /* Stays 14px: #invoicesTableWrap's margin-top:-14px is calibrated to cancel exactly this
     value so the invoices table header sits flush under the sticky toolbar. */
  margin-bottom: 14px;
  flex-wrap: wrap;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.toolbar input[type=text], .toolbar select {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-family: inherit;
  min-height: 36px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
.toolbar input[type=text]:hover, .toolbar select:hover { border-color: var(--border-strong); }
.toolbar select { cursor: pointer; }
#search {
  min-width: 240px;
  flex: 1 1 240px;
  max-width: 420px;
  /* Inline search glyph, drawn as a background image so no markup change is needed. */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236b6b68' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 10px 50%;
  padding-left: 32px;
}
.overdue-toggle {
  font-size: var(--fs-sm);
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  min-height: 36px;
  cursor: pointer;
  user-select: none;
  border-radius: var(--r-md);
  white-space: nowrap;
}
.overdue-toggle:hover { color: var(--ink); background: var(--panel-2); }
.overdue-toggle input { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.spacer { flex: 1; }

.table-wrap {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: auto;
  /* Cap the height so the table scrolls inside its own box, which keeps the
     column header frozen at the top (sticky) instead of scrolling off-page. */
  max-height: calc(100vh - 210px);
  box-shadow: var(--shadow-sm);
  /* Fades the right edge while a wide table is scrolled horizontally, so it is obvious there
     are more columns off-screen instead of the last visible column looking like the last one.
     Pure background-attachment trick - no JS, no extra markup. */
  background-image:
    linear-gradient(to right, var(--bg) 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), var(--bg) 70%),
    linear-gradient(to right, rgba(17,17,17,0.10), rgba(17,17,17,0)),
    linear-gradient(to left, rgba(17,17,17,0.10), rgba(17,17,17,0));
  background-position: 0 0, 100% 0, 0 0, 100% 0;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
/* Opt out of the own-box scroll above: used when the table's header should instead stick to
   the page scroll (stacked under other sticky sections, e.g. invoices.html's toolbar) rather
   than to a capped-height inner scrollbox - the two don't compose (a sticky child only sticks
   within its nearest *scrolling* ancestor, so as long as .table-wrap itself scrolls, the outer
   page scrolling it out of view takes the header with it). */
.table-wrap.flat-scroll {
  overflow: visible;
  max-height: none;
  /* The scroll-edge fade painted on .table-wrap above is meaningful only when the box scrolls
     its own overflow. On a flat-scroll wrapper the page scrolls instead, so those gradients
     would sit as fixed light bands over the first and last columns. */
  background-image: none;
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
/* Numeric columns: header AND cells centred together, so the label sits over its own data.
   Applied to BOTH th and td on purpose - styling only the td (the original mistake) left every
   header hard against the left edge while its numbers sat on the right, reading as two
   unrelated columns. Use this class rather than an inline text-align so a column can never
   again be aligned in one row type and not the other. */
/* NUMERIC COLUMNS ARE RIGHT-ALIGNED, HEADER AND CELLS TOGETHER (business owner, 2026-07-28:
   "align left except if the column has numbers"). Right, not centre, is the deliberate choice:
   right-alignment lines the decimal points and thousands up in a single vertical rule, so
   $430.00 next to $5,255.58 next to $166,031.47 can be compared at a glance by length alone.
   Centred numbers ragged both edges and that comparison is lost - which is the whole reason a
   finance table exists. tabular-nums keeps every digit the same width so the columns stay true
   even in a proportional font.
   Everything else stays LEFT (the default on the line above): SKUs, vendors, products and
   statuses are read as words, and words are read from their left edge.
   This is the single place alignment is set. Do not add text-align to a <th> or <td> anywhere
   else - put .num-col on the cell instead, on the header AND the body cell, or the two drift
   apart and the column reads as two unrelated things. */
th.num-col, td.num-col { text-align: right; font-variant-numeric: tabular-nums; }
/* NOTE: th padding (10px 12px), font-size (11px) and border-bottom (2px) are load-bearing -
   they add up to the rendered 38px header height that `#poTable .group-row td { top: 38px }`,
   `#ordersTable .group-row td { top: 38px }` and `.invoice-table .col-header th { top: 41px }`
   are hard-coded against. Only colour, weight and letter-spacing may be tuned here; changing
   any box-model value silently misaligns every frozen group header in the app. */
th { color: var(--text); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer; user-select: none; position: sticky; top: 0; z-index: 3; background: var(--panel-2); border-bottom: 2px solid var(--accent); transition: color var(--ease), background var(--ease); }
th:hover { color: var(--ink); background: var(--border); }
/* A touch more vertical room for the data rows only. Applied to tbody td rather than the
   shared `th, td` rule so the header's 38px height is left exactly as it was. */
tbody td { padding-top: 11px; padding-bottom: 11px; }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--panel); }
tbody tr:last-child td { border-bottom: none; }
td.notes-cell { white-space: normal; width: 340px; max-width: 340px; color: var(--text-dim); vertical-align: top; }
.notes-clip {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  cursor: help;
}
td.editable-row { cursor: pointer; }
td.lineitem-cell { vertical-align: top; white-space: nowrap; line-height: 1.6; }
label.checkbox-row { flex-direction: row; align-items: center; gap: 8px; }
.group-row td {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--ink-block);
  font-weight: 700;
  color: #ffffff;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
  letter-spacing: .02em;
}
td.grp-idx { color: var(--text-dim); text-align: center; vertical-align: top; }
.group-row .grp-name { font-size: 14px; color: #ffffff; }
.group-row .grp-total { float: right; font-weight: 600; font-size: 12px; color: #ffffff; }
.group-row .subtle { color: rgba(255,255,255,0.82); font-weight: 400; }
/* Order Status: freeze each section header (Lightspeed Kelowna / Shopify / Kirby &
   Andreas) just under the frozen column header (38px) while scrolling that section;
   the next section's header takes over as you reach it. separate border-collapse is
   required for a sticky <td> to hold mid-table in Chromium. */
#ordersTable { border-collapse: separate; border-spacing: 0; }
#ordersTable .group-row td { position: sticky; top: 38px; z-index: 2; }
/* PO Tracker: freeze each supplier's group header just under the frozen column header
   (38px) while scrolling that supplier's POs; the next supplier's header takes over. */
#poTable { border-collapse: separate; border-spacing: 0; }
#poTable .group-row td { position: sticky; top: 38px; z-index: 2; }
/* 3PL Invoices: freeze ONLY the top column-header line (Invoice #, Date, ...).
   The 3PL highlighted bars scroll normally with the invoices. */
#invoicesTable thead th { position: sticky; top: var(--sticky-table-top, 0); z-index: 5; }
#invoicesTable .group-row td { position: static; background: var(--ink-block); }
/* FIT THE WINDOW (2026-09-18, owner: "content must fit in desktop view or when zoom in or
   out"). The global `th, td { white-space: nowrap }` held every word of every cell on one line,
   so this 11-column table could not get narrower than all its text laid end to end, and the
   page scrolled sideways at every window size. Text columns wrap now. Figures, dates, invoice
   numbers, badges and the button stay on one line so they can still be read and compared at a
   glance. */
#invoicesTable th,
#invoicesTable td,
#invoicesTable .group-row td { white-space: normal; overflow-wrap: break-word; }
/* break-word, not anywhere: `anywhere` also shrinks a column's minimum width to one character,
   so the table layout squeezed the headers down to a letter per line. */
#invoicesTable td.num-col,
#invoicesTable td.mono,
#invoicesTable td:nth-child(2),
#invoicesTable .badge { white-space: nowrap; overflow-wrap: normal; }
#invoicesTable td:nth-last-child(2) { min-width: 220px; }   /* "What this covers" */
/* When even the wrapped table is wider than its box (a narrow or zoomed-in window), it scrolls
   inside its own box and the page stays still. invoices-app.js adds .is-overflowing only then,
   because a box that scrolls sideways also becomes the sticky container, so the column header
   stops pinning to the page. At normal widths the header keeps pinning as before. */
.table-wrap.flat-scroll.is-overflowing { overflow-x: auto; }
/* ID-qualified so it outranks `#invoicesTable thead th { top: var(--sticky-table-top) }`, which
   would otherwise push the header that far down inside the box. */
.table-wrap.flat-scroll.is-overflowing thead th,
#invoicesTableWrap.is-overflowing #invoicesTable thead th { position: static; }
/* Uniform font (same family + size) across the whole 3PL invoice table, so no
   cell stands out - normalizes the monospace invoice #, the 12px date/badge
   text, and the 14px 3PL bar to one consistent style. */
#invoicesTable th,
#invoicesTable td,
#invoicesTable .mono,
#invoicesTable .subtle,
#invoicesTable .grp-name,
#invoicesTable .grp-total,
#invoicesTable .badge,
#invoicesTable .days-badge,
#catalogTable td,
#catalogTable code,
#adjustmentsTable td,
#adjustmentsTable code,
/* Payment Tracker (added 2026-07-28): same uniform-font treatment as the 3PL invoice table,
   per the business owner - header and contents one family and one size, including the
   monospace PO/invoice numbers, the .subtle source text and every figure, so no cell stands
   out. Class-based rather than an id because that page renders one table per pay-run group. */
.pay-table th,
.pay-table td,
.pay-table .mono,
.pay-table .subtle,
.pay-table .badge,
.pay-table input.cell,
.pay-table textarea.cell {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

/* COLUMN HEADERS ARE EXEMPT FROM THE UNIFORM 13px ABOVE (2026-07-28, business owner).
   The rule above exists so that no CELL stands out - it normalises the monospace invoice
   numbers, the .subtle source text, the badges and every figure onto one family and size.
   It also swept the <th> in with them, which made these two tables the only ones in the app
   with a 13px / 41px-tall column header while Purchase Orders and Order Status use 11px /
   38.5px. Two consequences: the four tables no longer looked like one system, and at 13px the
   header was the same size as the data underneath it, so it read as another row rather than
   as the header of the column.
   Restoring 11px here fixes both while leaving the body cells fully uniform - the owner's
   actual concern (no single cell standing out) is untouched, because every td, .mono, .subtle,
   .badge and input in these tables still resolves to 13px from the rule above.
   Scoped to thead th so the black .group-row bands, which are data rows rather than column
   headers, keep their 13px treatment. Safe on height: nothing keys off the 41px these headers
   used to render at - #invoicesTable's sticky offset is measured live into --sticky-table-top,
   and the only hard-coded `top: 41px` belongs to the .invoice-table class block, which
   currently matches no elements on any page. */
#invoicesTable thead th,
.pay-table thead th {
  font-size: 11px;
}

/* 3PL Invoices: one table per 3PL, each with its own sticky <thead> so the
   highlighted 3PL bar + column header freeze while that 3PL's rows scroll. */
.invoice-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}
.invoice-table thead .group-row th {
  position: sticky;
  top: 0;
  z-index: 4;
  background: var(--ink-block);
  color: #ffffff;
  font-weight: 700;
  text-align: left;
  border-top: 2px solid var(--accent);
  border-bottom: 1px solid var(--border);
  letter-spacing: .02em;
  cursor: default;
}
.invoice-table thead .col-header th {
  /* frozen just below the 3PL bar so both stay pinned while the rows scroll */
  position: sticky;
  top: 41px;
  z-index: 3;
  background: var(--panel-2);
  color: var(--text);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-align: left;
  border-bottom: 2px solid var(--accent);
  cursor: default;
}
.invoice-table tbody td { overflow: hidden; text-overflow: ellipsis; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.2px;
  line-height: 1.5;
  white-space: nowrap;
  /* Each badge already carries a tinted background in its own .badge-* rule; a matching
     inset hairline gives the pill a defined edge on both the white table and the pale panel
     rows without needing a second colour value per status. */
  box-shadow: inset 0 0 0 1px rgba(17, 17, 17, 0.07);
}
.badge-clickable { cursor: pointer; text-decoration: underline; text-decoration-style: dotted; text-underline-offset: 2px; }
.badge-clickable:hover { filter: brightness(0.92); }
/* Badge backgrounds switched 2026-08-24 from per-badge rgba(oldcolor, alpha) literals to the
   shared soft-tint variables (good-soft/warn-soft/serious-soft/crit-soft/accent-soft) added
   above - solid tints instead of alpha overlays, matching inventory's .chip treatment exactly.
   Colors stay on the same --green/--yellow/--orange/--red/--accent variables as before, now
   pointing at inventory's hues instead of the old amber-brand ones. */
.badge-Ordered { background: var(--panel-2); color: var(--text-dim); }
.badge-Confirmed { background: var(--accent-soft); color: var(--accent); }
.badge-Shipped { background: rgba(124,92,191,0.14); color: var(--purple); }
.badge-In-Transit { background: var(--warn-soft); color: var(--yellow); }
.badge-Customs { background: var(--serious-soft); color: var(--orange); }
.badge-Delivered { background: var(--good-soft); color: var(--green); }
.badge-Received { background: var(--good-soft); color: var(--green); }
.badge-Delayed-Issue { background: var(--crit-soft); color: var(--red); }

/* 3PL invoice status badges */
.badge-Paid { background: var(--good-soft); color: var(--green); }
.badge-Unpaid { background: var(--warn-soft); color: var(--yellow); }
.badge-Disputed { background: var(--crit-soft); color: var(--red); }

/* Purchase Order payment-status badges */
.badge-Paid-in-Full { background: var(--good-soft); color: var(--green); }
.badge-Balance-Due { background: var(--warn-soft); color: var(--yellow); }
.badge-Unknown { background: var(--panel-2); color: var(--text-dim); }

/* Customer order-status badges */
.badge-in_stock { background: var(--good-soft); color: var(--green); }
.badge-backorder_eta { background: var(--warn-soft); color: var(--yellow); }
.badge-awaiting_eta { background: var(--serious-soft); color: var(--orange); }
.badge-unlinked { background: var(--crit-soft); color: var(--red); }
.badge-Processed { background: var(--accent-soft); color: var(--accent); }
.badge-Exception { background: var(--crit-soft); color: var(--red); }

.summary-card.risk { border-color: var(--red); }
.summary-card.risk .num { color: var(--red); }
.summary-card.ready { border-color: var(--green); }
.summary-card.ready .num { color: var(--green); }
.summary-card.stock { border-color: var(--accent); }
.summary-card.stock .num { color: var(--accent); }
#stockMatrix .stock-total td, #backorderMatrix .stock-total td, #remainingMatrix .stock-total td { border-top: 2px solid var(--border); font-weight: 600; }
#backorderMatrix .bom-sep td, #remainingMatrix .bom-sep td { background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 12px; padding: 6px 12px; border-top: 2px solid var(--accent); border-bottom: 1px solid var(--border); }
#backorderMatrix .bom-row td, #remainingMatrix .bom-row td { color: var(--text); }

/* Primary navigation.
   Rebuilt so the hover and active states share ONE shape. Previously hover drew a rounded
   1px box while active switched border-radius to 0 and swapped in a bottom border, so the
   same link changed geometry depending on state and the active tab read as a different
   component from its neighbours. Now both are a soft pill; active additionally carries an
   amber underline drawn with ::after, which does not participate in layout and therefore
   cannot nudge the row's height the way a real border-bottom did.
   The nav scrolls horizontally rather than wrapping or collapsing behind a toggle: all six
   destinations stay reachable in one gesture on a phone, and no JS is required for it. */
.nav-links {
  display: flex;
  gap: 2px;
  align-items: center;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
}
.nav-links::-webkit-scrollbar { display: none; }

.nav-link {
  position: relative;
  color: var(--text-dim);
  text-decoration: none;
  font-size: var(--fs-sm);
  font-weight: 500;
  padding: 8px 12px;
  border-radius: var(--r-md);
  border: 1px solid transparent;
  white-space: nowrap;
  flex: 0 0 auto;
  scroll-snap-align: start;
  transition: color var(--ease), background var(--ease);
}
/* Reserves the width of the bolder active label on every link, so moving between tabs never
   shifts the row horizontally as one label thickens and another thins. */
.nav-link::before {
  content: attr(data-label);
  display: block;
  height: 0;
  overflow: hidden;
  visibility: hidden;
  font-weight: 600;
  pointer-events: none;
}
.nav-link:hover { color: var(--ink); background: var(--panel-2); border-color: transparent; }
.nav-link.active {
  color: var(--ink);
  background: transparent;
  border-color: transparent;
  border-radius: var(--r-md);
  font-weight: 600;
}
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  /* Sits on the header's own bottom rule, so the active tab reads as physically connected to
     the page beneath it rather than as an underlined word floating above a separate line. */
  bottom: calc(-1 * (var(--sp-3) + 3px));
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
}
.nav-link.active:hover { background: var(--accent-soft); }

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.sku-map { color: var(--text-dim); }
.sku-map b { color: var(--text); }
td.eta-cell { font-weight: 600; }
.row-risk { background: rgba(208,59,59,0.06); }
.subtle { color: var(--text-dim); font-size: 12px; }
.days-badge { color: var(--text-dim); font-size: 12px; }
.days-badge.slow { color: var(--orange); font-weight: 600; }

.row-overdue td.eta-col { color: var(--red); font-weight: 600; }

.empty-state { padding: 60px 20px; text-align: center; color: var(--text-dim); }

/* Product Catalog: "Columns" show/hide panel (inventory-catalog-app.js). Preference is per
   column class (col-warehouse etc. on both the <th> and its matching <td>s); hiding just
   toggles a hide-col-X class on the table itself rather than re-rendering rows. */
.col-panel {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 30;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.col-panel label { display: flex; align-items: center; gap: 8px; font-size: 13px; white-space: nowrap; }
#catalogTable.hide-col-sku .col-sku,
#catalogTable.hide-col-name .col-name,
#catalogTable.hide-col-category .col-category,
#catalogTable.hide-col-warehouse .col-warehouse,
#catalogTable.hide-col-onhand .col-onhand,
#catalogTable.hide-col-available .col-available,
#catalogTable.hide-col-backorder .col-backorder,
#catalogTable.hide-col-cost .col-cost,
#catalogTable.hide-col-reorder .col-reorder,
#catalogTable.hide-col-supplier .col-supplier {
  display: none;
}

.row-actions { display: flex; gap: 6px; }
.row-actions button { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 14px; }
.row-actions button:hover { color: var(--accent); }

.modal-backdrop {
  display: none;
  position: fixed; inset: 0;
  background: rgba(17,17,17,0.55);
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 22px 24px;
  width: 640px;
  max-width: 92vw;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal h2 {
  margin-top: 0;
  margin-bottom: 4px;
  font-size: var(--fs-lg, 16px);
  font-weight: 700;
  letter-spacing: -0.2px;
  /* Keeps the dialog title in view while a long form (the PO editor runs to ~16 fields)
     is scrolled inside the modal, so the user never loses track of what they are editing. */
  position: sticky;
  top: -22px;
  z-index: 2;
  background: var(--bg);
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--border);
}
.modal .hint { font-size: var(--fs-xs); color: var(--text-dim); line-height: 1.5; }
.modal .hint code { background: var(--panel-2); padding: 1px 5px; border-radius: var(--r-sm); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.form-grid {
  display: grid;
  /* auto-fit lets the two-column form fold to one column on a narrow dialog without needing
     a breakpoint; it was previously a hard `1fr 1fr`, which stayed two-up at every width and
     squeezed date and number inputs below a usable size on a phone. */
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-3);
}
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  font-weight: 500;
}
label.full { margin-bottom: var(--sp-3); }
/* Spans the full grid width regardless of how many columns auto-fit resolved to. */
.form-grid label.full, .form-grid label.checkbox-row { grid-column: 1 / -1; }
input, select, textarea {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--r-md);
  font-size: var(--fs-sm);
  font-family: inherit;
  min-height: 36px;
  transition: border-color var(--ease), box-shadow var(--ease);
}
textarea { min-height: 72px; resize: vertical; line-height: 1.5; }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
/* Retains the original amber focus border, but no longer as a replacement for the focus
   ring - the global :focus-visible rule above supplies the actual accessible indicator. */
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
input[type=checkbox] { min-height: 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; }
#pasteArea { width: 100%; margin-top: 10px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.modal-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--border);
  align-items: center;
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--ink-block);
  border: 1px solid var(--ink-block);
  color: #ffffff;
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(17,17,17,0.25);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* ---------------------------------------------------------------------------
   Shared "insight block" styling. Lifted out of insights.html's inline <style>
   on 2026-07-27 when the "Before you reorder" block moved onto the Purchase
   Order page - it needs to look identical wherever it is hosted, and an inline
   style on one page cannot do that.
   The heading reuses the .ins-cat-head / h2 shape so a hosted block reads as a
   section of the page, not a bolted-on panel.
   The accent left rule was removed on 2026-07-27 at the business owner's request,
   together with the "Before you reorder — read this" heading it belonged to: the
   rule existed to mark the block out as a pre-read callout, and with that framing
   gone it was just a stray vertical line running the height of two tables.
   .ins-block is used only by reorder-block.js, so nothing else is affected.
   --------------------------------------------------------------------------- */
.ins-block { margin-bottom: 34px; }
.ins-block h2 { font-size: 16px; margin: 0; }
/* The subheading that used to sit between this title and the first table supplied the gap under
   it; with that promoted to be the title, .ins-cat-head's own 4px left the heading jammed against
   the table. Scoped to .ins-block so the Order Status page's heading spacing is not affected. */
.ins-block .ins-cat-head { margin-bottom: 12px; }
/* A second heading of the same rank further down the block needs to clear the table above it. */
.ins-block .ins-cat-head-sub { margin-top: 28px; }
.ins-block-body { padding: 0; }
.ins-cat-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.ins-cat-num { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--accent); font-weight: 700; }
/* Tables use the system table style above; only the two things that differ are restated -
   a top margin, and cursor:default because these headers do not sort. */
.ins-block table { margin-top: 6px; }
.ins-block th { cursor: default; }
.ins-block th:hover { color: var(--text); }
.ins-block th.num-col, .ins-block td.num-col { text-align: right; font-variant-numeric: tabular-nums; }
.ins-block td.num-col { font-variant-numeric: tabular-nums; }
.ins-scroll-table { max-height: 260px; overflow-y: auto; }
.ins-scroll-table thead th { position: sticky; top: 0; background: var(--panel, #fff); z-index: 1; }

/* ===========================================================================
   Insight section styles. Moved out of insights.html's inline <style> on
   2026-07-27 when the Insights page was broken up and its sections were
   distributed to the pages that act on them (stock/waiting -> Order Status,
   cost -> 3PL Invoices, reorder/containers -> Purchase Order). A section has
   to look the same wherever it is hosted, and an inline style on one page
   cannot do that. Some rules duplicate the .ins-block set appended above;
   they are identical values, so whichever wins renders the same.
   =========================================================================== */
  .ins-category { margin-bottom: 34px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
  .ins-category:last-child { border-bottom: none; }
  .ins-cat-head { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
  .ins-cat-num { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--accent); font-weight: 700; }
  .ins-category h2 { font-size: 16px; margin: 0; }
  .ins-cat-desc { font-size: var(--fs-sm); color: var(--muted); max-width: 820px; margin: 2px 0 12px; }
  .ins-recommendation { display: flex; gap: 10px; align-items: flex-start; background: var(--accent-soft); border: 1px solid var(--accent); border-radius: 4px; padding: 10px 14px; margin-bottom: 14px; font-size: 13.5px; }
  .ins-recommendation .icon { flex-shrink: 0; }
  /* Group headings. Five themed groups so the page reads as an argument - money in, can we
     supply it, what the customer feels, what it costs, what to watch - rather than seven
     equally-weighted panels in the order they happened to be built. */
  .ins-group { display: flex; align-items: baseline; gap: 14px; margin: 40px 0 16px;
               padding-bottom: 10px; border-bottom: 2px solid var(--ink); }
  .ins-group:first-of-type { margin-top: 8px; }
  .ins-group-n { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 22px;
                 font-weight: 700; color: var(--accent); line-height: 1; }
  .ins-group-h { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.2px; }
  .ins-group-d { margin: 4px 0 0; font-size: 12px; color: var(--muted); line-height: 1.5; max-width: 780px; }

  /* Top blocker panel. Deliberately louder than a normal section: it exists to stop a reader
     acting on the oversold numbers below without first checking whether the stock is already
     inbound. */
  /* Reads as a normal section, not a red alert box. The bespoke red panel was visually louder
     than anything else on the page while saying something that is routine context, and the
     mismatch made it read as an error. Header uses the shared .ins-cat-head / h2 pattern. The
     accent left rule that used to mark it out as a pre-read was removed on 2026-07-27 with the
     "Before you reorder" heading - see the note on the .ins-block set above. */
  .ins-block { margin-bottom: 34px; }
  /* .ins-category h2 is scoped to that class, so repeat the size here to keep this heading
     identical to sections 01-07 rather than falling back to the browser default. */
  .ins-block h2 { font-size: 16px; margin: 0; }
  .ins-block-body { padding: 0; }
  .ins-block-lead { font-size: 14px; line-height: 1.6; margin: 0 0 12px; }
  .ins-block-lead strong { font-weight: 700; }
  .ins-strike { text-decoration: line-through; color: var(--muted); }
  /* Tables here use the SYSTEM table style from style.css - same grey header bar, same accent
     underline, same padding as every other table in the app. The old overrides below set a
     muted, lighter, unbacked header that looked like a different product. Only two things are
     restated: a top margin, and cursor:default because these headers do not sort (style.css
     sets cursor:pointer for the sortable tables it was written for). */
  .ins-block table { margin-top: 6px; }
  .ins-block th { cursor: default; }
  .ins-block th:hover { color: var(--text); }
  /* Kept after the th override above was removed: harmless now that style.css's th.num-col
     applies cleanly, but it costs nothing and guards against a future scoped th rule
     re-introducing the left-align bug this was written to fix. */
  .ins-block th.num-col, .ins-block td.num-col { text-align: right; font-variant-numeric: tabular-nums; }
  .ins-block td.num-col { font-variant-numeric: tabular-nums; }

  .ins-kpi-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
  .ins-kpi-card { border: 1px solid var(--border); border-left-width: 3px; border-radius: 0 4px 4px 0; padding: 12px 16px; background: var(--panel); min-width: 140px; }
  .ins-kpi-card .v { font-size: 22px; font-weight: 700; }
  .ins-kpi-card .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-top: 3px; }
  .ins-kpi-card .d { font-size: 11px; color: var(--muted); margin-top: 1px; }
  /* Added 2026-07-18: these counts used to render in the same plain black as every other KPI
     regardless of severity, even though the tables below them already color-code the exact same
     critical/warning concept (.ins-alert, .badge-critical) - the one number most worth noticing
     at a glance ("9 Critical Alerts") had no more visual weight than "3.1 Avg Cancellations/Day".
     Reuses the identical colors/left-border language .ins-alert already established, rather than
     inventing a second severity vocabulary. */
  .ins-kpi-card.critical { border-left-color: var(--red, #c0392b); }
  .ins-kpi-card.critical .v { color: var(--red, #c0392b); }
  .ins-kpi-card.warning { border-left-color: var(--yellow, #b8860b); }
  .ins-kpi-card.warning .v { color: var(--yellow, #b8860b); }
  .ins-gap-note { font-size: 12px; color: var(--muted); background: var(--panel-2); border-left: 3px solid var(--muted); padding: 8px 12px; border-radius: 0 4px 4px 0; margin-bottom: 12px; }
  .ins-alert { display: flex; gap: 10px; padding: 9px 12px; border: 1px solid var(--border); border-left-width: 3px; border-radius: 0 4px 4px 0; margin-bottom: 6px; font-size: 13px; }
  .ins-alert.critical { border-left-color: var(--red, #c0392b); }
  .ins-alert.warning { border-left-color: var(--yellow, #b8860b); }
  .ins-alert.info { border-left-color: var(--muted); }
  .ins-alert .cat { font-size: var(--fs-2xs, 11px); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; min-width: 130px; flex-shrink: 0; }
  .ins-scroll-table { max-height: 260px; overflow-y: auto; }
  .ins-scroll-table thead th { position: sticky; top: 0; background: var(--panel, #fff); z-index: 1; }
  #skuForecastTable td, #skuForecastTable th { white-space: nowrap; }
  /* Supplier group bands scroll with the table (no sticky), same as the invoices table. */
  #skuForecastTable .group-row td { position: static; }
  #skuForecastTable td.product-cell, #skuForecastTable th.product-cell { white-space: normal; max-width: 240px; }
  .badge-alert { font-size: var(--fs-2xs, 11px); font-weight: 700; text-transform: uppercase; padding: 2px 6px; border-radius: 3px; }
  .badge-critical { color: var(--red); background: var(--crit-soft); }
  .badge-low_stock { color: var(--red); background: var(--crit-soft); }
  .badge-overstock { color: var(--purple); background: rgba(124,92,191,0.14); }
  .badge-no_sales { color: var(--yellow); background: var(--warn-soft); }
  .badge-no_demand_data { color: var(--muted); background: var(--panel-2); }
  .stock-cell { cursor: pointer; }
  .stock-breakdown { font-size: 11px; color: var(--muted); margin-top: 3px; line-height: 1.5; white-space: nowrap; }

/* ===========================================================================
   EMPTY / ZERO STATES
   =========================================================================== */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-dim);
  font-size: var(--fs-md);
  line-height: 1.6;
}

/* ===========================================================================
   RESPONSIVE LAYER
   Added 2026-07-28. Before this the stylesheet contained no @media rules at
   all: the header, the filter toolbar, the two-column PO form and every table
   were laid out for a wide desktop only, so on a tablet the nav and the action
   buttons fought for the same row, and on a phone the brand wordmark was
   squeezed until it visually clipped mid-word.
   The approach is deliberately JS-free. Nothing here hides a control, removes
   a column or collapses navigation behind a toggle - every destination, filter
   and button present on desktop is still present and reachable at 360px. Only
   the arrangement changes.
   =========================================================================== */

/* --- Laptop / small desktop ------------------------------------------------ */
@media (max-width: 1200px) {
  :root { --app-pad: 20px; }
  .summary { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
}

/* --- Short window, or zoomed in -------------------------------------------------
   Added 2026-09-18. 3PL Invoices pins four bands (topbar, summary tiles, the 3PL matrix and
   the filter toolbar), about 420px together. On a 768px-tall laptop that left ~330px for the
   invoices, and zoomed in to 125-150% the pinned bands covered nearly the whole window. Below
   900px of height the summary and matrix scroll away with the page, and only the toolbar and
   the column header stay pinned. invoices-app.js measures only the bands that are really pinned,
   so the toolbar sits straight under the topbar with no gap. */
@media (max-height: 900px) {
  .summary.sticky-summary,
  .table-wrap.sticky-matrix { position: static; }
}

/* --- Tablet ---------------------------------------------------------------- */
@media (max-width: 900px) {
  :root { --app-pad: 18px; }

  /* The brand+nav cluster takes the full first row and the action buttons drop to their
     own row beneath it. Both rows stay inside the same sticky header, so --topbar-h (which
     nav-reports-link.js measures live) still resolves correctly and the frozen table
     headers keep sitting directly underneath it. */
  .topbar { align-items: stretch; row-gap: 10px; }
  .topbar-left,
  .topbar > div:first-child:not(.topbar-actions) { flex: 1 1 100%; gap: var(--sp-4); }
  .topbar-actions { margin-left: 0; width: 100%; justify-content: flex-start; }

  /* The active-tab underline is anchored to the header's bottom rule on desktop. Once the
     actions wrap to a second row that rule is no longer directly below the nav, so the
     underline returns to sitting just under its own label. */
  .nav-link.active::after { bottom: -6px; }

  .table-wrap { max-height: calc(100vh - 260px); }
  .modal { padding: 20px; }
}

/* --- Mobile ---------------------------------------------------------------- */
@media (max-width: 640px) {
  :root { --app-pad: 14px; }

  .topbar { padding-bottom: 10px; row-gap: 8px; }

  /* The stacked two-line wordmark costs vertical space that a phone header cannot spare,
     and it was the element being clipped. It becomes a single compact line, keeping the
     accent rule that identifies it. */
  .brand { flex-direction: row; align-items: baseline; gap: 6px; font-size: var(--fs-sm); }
  .brand span { font-size: 8px; letter-spacing: 2px; }

  /* Edge-to-edge scrolling nav: the strip bleeds into the page gutters so it is obvious
     the row continues past the screen edge, and the tab under the finger is never clipped
     by the page padding. */
  .nav-links {
    margin-inline: calc(var(--app-pad) * -1);
    padding-inline: var(--app-pad);
    scroll-padding-inline: var(--app-pad);
  }

  /* Controls reach a comfortable thumb size and the primary action takes the full width
     rather than sitting as a small target in a crowded row. */
  .topbar-actions { gap: 6px; }
  .topbar-actions .btn { flex: 1 1 auto; min-height: 40px; }

  .summary { grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); gap: var(--sp-2); }
  .summary-card { padding: 12px; }
  .summary-card .num { font-size: var(--fs-xl); }

  /* Search takes its own full row above the remaining filters so it is never reduced to a
     stub, then the status select and the overdue toggle share the row below it. */
  .toolbar { padding: 10px; gap: 8px; }
  #search { flex: 1 1 100%; max-width: none; min-width: 0; }
  .toolbar select { flex: 1 1 auto; }
  .toolbar .btn { flex: 1 1 auto; }
  .spacer { display: none; }

  /* Tables keep every column and scroll horizontally inside their own rounded container -
     no column is dropped, because on this app a hidden column is a hidden commitment. */
  .table-wrap { max-height: calc(100vh - 300px); border-radius: var(--r-md); }

  /* Dialogs become a bottom sheet: full width, flush to the bottom edge, which is where a
     thumb actually is. */
  .modal-backdrop { align-items: flex-end; }
  .modal {
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: var(--r-lg) var(--r-lg) 0 0;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .modal h2 { top: -18px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal-actions .btn { flex: 1 1 auto; min-height: 42px; }
  /* Destructive action separated from the confirm/cancel pair so it is not fat-fingered. */
  .modal-actions #btnDelete { flex: 1 1 100%; order: 3; }

  .toast { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

@media (max-width: 400px) {
  :root { --app-pad: 12px; }
  .summary { grid-template-columns: 1fr 1fr; }
  .nav-link { padding: 8px 10px; }
}

/* --- Touch input ----------------------------------------------------------- */
/* Applies by input capability rather than width, so a large touchscreen gets the same
   comfortable targets as a phone. */
@media (pointer: coarse) {
  .btn, .toolbar input[type=text], .toolbar select, input, select, textarea { min-height: 42px; }
  .nav-link { padding-top: 10px; padding-bottom: 10px; }
  .row-actions button { min-width: 40px; min-height: 40px; }
  input[type=checkbox] { width: 18px; height: 18px; }
}

/* --- Accessibility --------------------------------------------------------- */
/* The prefers-contrast override moved to design-tokens.css 2026-08-27 (token values belong there). */


/* Screen-reader-only utility, available to any page that needs to name a control whose
   visible label is an icon or a glyph. */
.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* --- Print ----------------------------------------------------------------- */
/* These tables get printed for pay runs and supplier meetings; the sticky chrome and the
   capped scroll box both actively break that, so print gets a flat, full-length document. */
@media print {
  .topbar, .toolbar, .modal-backdrop, .toast { display: none !important; }
  .app { padding: 0; }
  .table-wrap { max-height: none; overflow: visible; border: none; box-shadow: none; background-image: none; }
  th { position: static !important; }
  .group-row td, #poTable .group-row td, #ordersTable .group-row td { position: static !important; }
  table { font-size: 10px; }
  tbody tr:hover { background: none; }
}

/* Inputs edited directly inside a table cell (the Payment Tracker's status/notes/category
   fields) opt out of the 36px control height. That height is right for a form, but the pay
   table is a dense 13-column grid worked top-to-bottom, and applying it there added roughly a
   third to every row for no gain on a precise pointer. Touch still gets a full-size target
   via the pointer:coarse rule below. */
@media (pointer: fine) {
  .pay-table input.cell,
  .pay-table textarea.cell,
  table td input,
  table td select,
  table td textarea {
    min-height: 30px;
    padding-top: 5px;
    padding-bottom: 5px;
  }
}
@media (pointer: coarse) {
  .pay-table input.cell, .pay-table textarea.cell { min-height: 42px; }
}

/* ===========================================================================
   PAGE HEADER BAND
   Added 2026-07-28. Not one page in the app carried an <h1>: every screen went
   straight from the global nav into a toolbar and a table, so the only thing
   naming the current view was the browser tab. That left the document outline
   starting at <h2> (and those <h2>s live inside modals, so the outline was
   effectively random), and it left "how fresh is this data" sitting in three
   different places - inside .topbar-actions on three pages, a bespoke #shipSynced
   on Shipments, and nowhere at all on Purchase Order.
   This band gives every page the same three slots in the same order: what you are
   looking at, an optional one-line orientation, and the state of the data. It adds
   no new information - the titles are the nav labels the user just clicked and the
   meta is the existing synced element, relocated.
   =========================================================================== */
.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin: 0 0 var(--sp-5);
}
.page-head-text { min-width: 0; }
.page-title {
  margin: 0;
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.3px;
  line-height: 1.2;
  color: var(--ink);
}
.page-desc {
  margin: 5px 0 0;
  font-size: var(--fs-sm);
  color: var(--text-dim);
  line-height: 1.5;
  max-width: 78ch;   /* keeps orientation copy to a readable measure on wide screens */
}
/* Data-state slot. Right-aligned on desktop so it reads as metadata about the page
   rather than as a second heading, and drops under the title on narrow screens. */
.page-head-meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
  font-size: var(--fs-xs);
  color: var(--text-dim);
  margin-left: auto;
  padding-bottom: 2px;
}
.page-head-meta .subtle { font-size: var(--fs-xs); }

@media (max-width: 640px) {
  .page-head { margin-bottom: var(--sp-4); gap: var(--sp-2); }
  .page-title { font-size: var(--fs-lg); }
  .page-head-meta { margin-left: 0; }
}
@media print {
  .page-head { margin-bottom: 12px; }
  .page-title { font-size: 14px; }
}

/* ===========================================================================
   HEADER QUEUE BUTTONS (Order Status, Purchase Order)
   Order Status puts six controls in the action bar, five of which are alert
   queues: Customer messages, Customer updates, For Follow up, Exceptions and
   Action Center. Rendered as five equal-weight buttons they competed with each
   other and with the page itself, and their count badges were each declared
   with slightly different inline padding/radius, so no two lined up.
   These rules re-rank them WITHOUT removing anything: the four queues become a
   compact secondary cluster, Action Center keeps its primary treatment as the
   way in, and every badge is normalised to one shape.
   The badge colours are deliberately NOT touched - red on messages/exceptions
   vs amber on updates/follow-ups is a severity distinction that carries meaning,
   and flattening it would destroy information. !important is required only
   because those values are set as inline style attributes in the markup, which
   no selector can otherwise override.
   =========================================================================== */
#btnCustomerNotifs,
#btnPendingDrafts,
#btnFollowupDrafts,
#btnExceptions,
#btnSupplierFollowups {
  padding: 7px 11px;
  font-weight: 500;
  color: var(--text-dim);
  box-shadow: none;
}
#btnCustomerNotifs:hover,
#btnPendingDrafts:hover,
#btnFollowupDrafts:hover,
#btnExceptions:hover,
#btnSupplierFollowups:hover { color: var(--ink); background: var(--panel-2); }

/* One badge shape everywhere. Size/alignment only - colour stays as authored. */
#notifBadge, #draftsBadge, #followupBadge, #exceptionsBadge,
#actionCenterBadge, #supplierFollowupBadge {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-width: 18px !important;
  height: 18px !important;
  padding: 0 5px !important;
  border-radius: var(--r-pill) !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  margin-left: 6px !important;
  font-variant-numeric: tabular-nums;
}
/* Action Center is the entry point to the queues, so it keeps the primary weight. */
#btnActionCenter { font-weight: 700; }

/* ===========================================================================
   SHIPMENTS - responsive behaviour for its page-scoped components
   shipments.html carries its own ~6.8kB <style> block. It is properly scoped to
   .ship-* and well commented, but it was written entirely in fixed pixel grids
   (a 34px/1fr/auto queue row, a 94px/1fr detail band) with no narrow-viewport
   handling, so on a phone the rank chip, the text and the action buttons were
   crushed into three unusable columns. Restated here rather than in that inline
   block so the page's responsive rules live with every other responsive rule in
   the system instead of in a second, invisible place.
   =========================================================================== */
/* NOTE ON SPECIFICITY: shipments.html loads its inline <style> AFTER style.css, so at equal
   specificity the page block wins and a media query does not change that - these overrides
   silently did nothing until they were prefixed with .app to outrank it. Any future rule
   targeting a .ship-* class from this file needs the same prefix. */
@media (max-width: 640px) {
  .app .ship-queue-row { grid-template-columns: 26px 1fr; gap: 10px; padding: 12px; }
  /* The action buttons drop to their own full-width row under the text they act on,
     instead of being squeezed into a third column a thumb cannot hit. */
  .app .ship-queue-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: stretch;
    flex-wrap: wrap;
    margin-top: 4px;
  }
  .app .ship-queue-actions .btn { flex: 1 1 auto; font-size: 13px; padding: 8px 12px; }
  .app .ship-band > div { grid-template-columns: 1fr; gap: 2px; padding: 5px 0; }
  .app .ship-band-k { font-size: var(--fs-2xs, 11px); }
  .app .ship-head { padding: 12px; }
  .app .ship-head-right { text-align: left; }
  .app .ship-title { font-size: var(--fs-md); }
  .app .ship-group-name { font-size: var(--fs-lg); }
  .app .ship-step { grid-template-columns: 26px 1fr; gap: 10px; padding: 7px 12px; }
  .app .ship-firstup h2 { padding: 11px 12px; }
}

/* ===========================================================================
   SYSTEM-WIDE TABLE BODY TYPOGRAPHY (2026-07-28, business owner)
   The uniform-font treatment further up this file was only ever applied to four
   tables (#invoicesTable, .pay-table, #catalogTable, #adjustmentsTable). Every
   other table in the app kept the raw component defaults, so the body of one
   table did not match the body of another - and within a single table the cells
   did not even match each other. Measured on Order Status before this rule:
     plain td 13px · .subtle 12px · .badge 12px · .days-badge 12px
     .grp-total 12px · .grp-name 14px
   Four different sizes stacked in one grid, against a flat 13px on 3PL Invoices
   and Payments. That is what made the pages read as separate products.
   This generalises the SAME treatment the owner already approved to every table
   in the system, so the content under the header is one family and one size
   wherever it appears. Descendant selectors (table .x) outrank the bare
   component rules (.x) on specificity, so ordering in this file is irrelevant
   and nothing needs !important.
   Column headers are NOT included - they stay 11px via the base th rule, which
   is what makes a header read as a header rather than as another data row.
   =========================================================================== */
table td,
table .mono,
table .subtle,
table .badge,
table .days-badge,
table .grp-name,
table .grp-total,
table code,
table input.cell,
table textarea.cell {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
}

/* Deliberate exceptions: sub-annotations and small uppercase status tags printed
   alongside or under a value, rather than being cell content in their own right.
   Promoting these to 13px would make them compete with the figure they annotate and
   would visibly inflate the forecast and pay-run rows, so they keep a smaller scale.
   They are pinned to ONE scale (11px) rather than the two the app had grown into -
   .avoid-tag / .info-tag on the Payment Tracker and the reorder-block labels were
   11px while .badge-alert in the forecast tables was 10px, so the same idea (a small
   uppercase tag qualifying a number) rendered at two different sizes depending on
   which page you were looking at. */
table .stock-breakdown,
table .badge-alert,
table .avoid-tag,
table .info-tag { font-size: 11px; }

/* The two group-band labels need a specificity bump to be reached: `.group-row .grp-name`
   and `.group-row .grp-total` are two-class selectors (0,2,0), which outrank the
   `table .grp-name` form above (0,1,1), so those bands kept their old 14px title / 12px
   total while every other cell moved to 13px. Adding the table element raises these to
   (0,2,1) so the band matches the rest of the body - which is already how the bands render
   on 3PL Invoices, where #invoicesTable .grp-name has been normalising them to 13px all
   along. Colour, weight and the float on .grp-total are untouched, so the band still reads
   as a band. */
table .group-row .grp-name,
table .group-row .grp-total {
  font-size: 14px;
}

/* Buttons do not inherit the page font by default - the UA supplies its own (Arial here).
   .btn already sets font-family: inherit, but the bare <button>s rendered inside table rows
   by .row-actions never did, so the Edit/Delete controls in every PO row were the only text
   in the whole application rendering in a different typeface from everything around them.
   Set on the element rather than just .row-actions so any future unclassed button is covered
   too. Does not touch size, colour or spacing. */
button { font-family: inherit; }

/* Delay-risk tag on the Purchase Order ETA column (rendered by app.js). Its background
   colour stays inline because it is data - green/amber/red encodes Low/Medium/High - but
   its shape and scale live here so it sits on the same 11px pill scale as the other small
   status tags rather than being a lone 10px, 8px-radius element. */
.risk-chip {
  display: inline-flex;
  align-items: center;
  border-radius: var(--r-pill);
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.5;
  margin-left: 4px;
  white-space: nowrap;
}

/* ===========================================================================
   SORT AFFORDANCE
   The base `th` rule sets cursor:pointer and a hover colour change on EVERY
   table header in the app, but only the Purchase Order table actually wires up
   click-to-sort (its <th>s carry data-sort). Order Status, 3PL Invoices and the
   Payment Tracker have no sort handler at all - Order Status sorts through a
   separate "Sort:" dropdown in its toolbar instead. So on three of the four
   tables every column header invites a click and then does nothing, which reads
   as a broken control rather than a static label.
   Affordance now follows capability: only a header that can actually sort shows
   a pointer and reacts to hover. Nothing is hidden or removed - non-sortable
   headers simply stop pretending to be buttons.
   =========================================================================== */
th:not([data-sort]) { cursor: default; }
th:not([data-sort]):hover { color: var(--text); background: var(--panel-2); }

/* A sortable header earns a visible affordance instead of relying on the cursor
   alone: a faint chevron that firms up on hover, so the sortable columns are
   discoverable without having to hunt for them. */
th[data-sort]::after {
  content: "⌃";
  display: inline-block;
  transform: rotate(180deg) translateY(2px);
  margin-left: 6px;
  font-size: var(--fs-2xs, 11px);
  opacity: 0.28;
  transition: opacity var(--ease);
}
th[data-sort]:hover::after { opacity: 0.75; }

/* Payment Tracker - derived ageing badge (payments-app.js ageBadge()).
   States the due-date position mechanically so the free-text status field beside it can hold
   the human half - what is being done about it - instead of the two being mixed in one string.
   Sits on the same 11px uppercase tag scale as AVOIDABLE / NEEDS AMOUNT rather than inventing
   a third size, and reuses the app's existing severity colours. */
.pay-age {
  display: inline-block;
  margin-bottom: 4px;
  padding: 2px 7px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}
.pay-age.late { background: rgba(192, 57, 43, 0.14); color: var(--red); }
.pay-age.due  { background: rgba(184, 134, 11, 0.16); color: var(--yellow); }
.pay-age.ok   { background: rgba(26, 127, 75, 0.12); color: var(--green); }
/* "No due date" is not a mild state - nothing exists to make these come due, so they rot
   quietly. Coloured as a warning rather than as neutral metadata. */
.pay-age.none { background: rgba(193, 88, 10, 0.14); color: var(--orange); }

/* ===========================================================================
   SIDEBAR NAVIGATION
   Added 2026-08-26 per the business owner - same visual format as Forward
   Inventory's sidebar (dark column, grouped section labels, icon rows),
   applied to this app's own pages. Layout only changes shape: every page,
   link and button that existed in the old .topbar-left/.nav-links row still
   exists and is reachable - it just now lives in .sidebar instead. .app is
   otherwise untouched and still governs the scrolling content column exactly
   as before; .shell is a new flex wrapper around .sidebar + .app, so every
   existing `position: sticky; top: var(--topbar-h)` rule in this file keeps
   resolving against the same page-level scroll it always used (no nested
   scroll container introduced by this change).
   Mobile follows this file's existing 2026-07-28 RESPONSIVE LAYER rule
   ("deliberately JS-free... nothing hidden behind a toggle"): under 900px
   the sidebar becomes a horizontal scrolling strip, not a hamburger-hidden
   drawer, and .topbar's own sticky offset is adjusted to sit right below it
   instead of overlapping it.
   =========================================================================== */

.shell { display: flex; align-items: flex-start; }
.shell > .app { flex: 1 1 auto; min-width: 0; }
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-ink);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 31;
  border-right: 1px solid var(--border);
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; font-size: var(--fs-md, 14px); font-weight: 700; letter-spacing: 0.5px; color: var(--text); line-height: 1.25; flex-shrink: 0; }
.sidebar-brand-icon { font-size: 20px; }
.sidebar #nav { flex: 1; overflow-y: auto; padding: 6px 10px 20px; }
.nav-section { font-size: var(--fs-2xs, 11px); text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 16px 10px 4px; font-weight: 700; }
.nav-section:first-child { padding-top: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm);
  color: var(--sidebar-ink); font-size: 13px;
  text-decoration: none; margin-bottom: 1px;
}
.nav-item:hover { background: var(--sidebar-hover); color: var(--text); text-decoration: none; }
/* Inventory's active treatment: a tinted pill, not a solid block - the accent points, the
   sidebar stays quiet. */
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-item .ico { width: 20px; text-align: center; font-size: 14px; opacity: .9; flex-shrink: 0; }
.nav-item.active .ico { opacity: 1; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: 50px; position: sticky; top: 0; flex-direction: row; align-items: center; overflow-x: auto; overflow-y: hidden; padding: 0; }
  .sidebar-brand { display: none; }
  .sidebar #nav { flex: none; display: flex; flex-direction: row; align-items: center; padding: 0 10px; overflow-x: auto; white-space: nowrap; height: 100%; }
  .nav-section { padding: 0 10px; white-space: nowrap; flex-shrink: 0; }
  .nav-section:first-child { padding-top: 0; }
  .nav-item { white-space: nowrap; margin-bottom: 0; flex-shrink: 0; }
  /* Sit right below the 50px sidebar strip instead of overlapping it - same -1px flush
     trick as the desktop rule above, just offset by the strip's height. */
  .topbar { top: 49px; }
}


/* ---------------------------------------------------------------------------
   NIGHT MODE (added 2026-08-27, owner request). Same token names, dark values -
   nothing below the token layer knows which theme is active. Three states:
   the theme.js toggle stamps data-theme="dark"/"light" on <html> (persisted in
   localStorage as 'ff-theme'); with no explicit choice the OS preference wins
   via the media query. The palette keeps Forward Inventory's navy-grey
   undertone (16,24,40) rather than flat black, status hues are lightened to
   hold AA contrast on the dark panels, and their -soft tint pairs are re-baked
   as deep solid tints so badges keep the same "solid tint behind darkened
   (now lightened) text" treatment as light mode.
   --------------------------------------------------------------------------- */



/* The inline search glyph is a data-URI SVG with a baked-in mid-grey stroke -
   readable on both themes, but in dark mode it sits on a dark input, so give
   inputs their themed surface explicitly (they inherited white from UA styles
   only in light mode's color-scheme). */
input, select, textarea { background-color: var(--panel); color: var(--text); }

/* Theme toggle. Lives in .topbar-actions on the app pages; floats on pages
   without a topbar (login, track-order). */
.theme-toggle { font-size: var(--fs-md, 14px); line-height: 1; }
.theme-toggle-floating {
  position: fixed; top: 14px; right: 14px; z-index: 600;
  width: 38px; height: 38px; border-radius: var(--r-pill);
  background: var(--panel); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm); cursor: pointer; font-size: 16px; line-height: 1;
}
.theme-toggle-floating:hover { border-color: var(--border-strong); }

/* Gentle cross-fade when the theme flips; cheap enough to leave on always. */
body, .sidebar, .panel, .card, .topbar, .btn, .nav-item, input, select, textarea { transition: background-color .12s ease, color .12s ease, border-color .12s ease, box-shadow .12s ease; }

/* Inventory's thin, quiet scrollbars + visible keyboard-focus ring. */
* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ===========================================================================
   FORWARD INVENTORY PAGE FORMAT (2026-09-29, owner: "do the same format similar to"
   the inventory app's Kelowna Store page). LOOK ONLY - no markup, menu or data change,
   and the top bar (Log out / theme / Reload) deliberately stays where it is.
   Each rule below mirrors inventory/public/styles.css so the two apps read as one:
     page head  title 22px with the count line UNDER it, not pushed to the right
     tiles      white card, label above a 27px figure, colour only as a 3px left edge
     filters    a plain row of controls above the table, no panel around them
     table      one white box; quiet muted headers with a hairline, not a blue rule
     chips      every status pill carries a dot, as inventory's .chip does
   Sits last in the file so it wins without editing the older rules above it; it
   uses tokens only, so night mode follows automatically.
   =========================================================================== */
.page-head { flex-direction: column; align-items: flex-start; justify-content: flex-start; gap: 2px; margin-bottom: var(--s5); }
.page-title { font-size: 22px; letter-spacing: -.01em; }
.page-head-meta { margin-left: 0; padding-bottom: 0; font-size: 13px; color: var(--muted); }
.page-head-meta .subtle { font-size: 13px; color: var(--muted); }

.summary { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--s3); margin-bottom: var(--s5); }
.summary-card {
  display: flex; flex-direction: column;
  position: relative; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s3) var(--s4);
}
.summary-card .label { order: -1; margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .01em; text-transform: none; color: var(--muted); }
.summary-card .num { font-size: 27px; letter-spacing: -.02em; }
.summary-card.clickable:hover { border-color: var(--accent); box-shadow: var(--shadow-lift); transform: none; }
/* overdue/risk/bad = red, warn = amber, ready = green, stock = blue (the class names the
   3PL, Payments and Freight Claims pages already put on their tiles). */
.summary-card.overdue, .summary-card.risk, .summary-card.bad, .summary-card.warn, .summary-card.ready, .summary-card.stock { border-color: var(--hairline); padding-left: calc(var(--s4) - 3px); }
.summary-card.overdue::before, .summary-card.risk::before, .summary-card.bad::before, .summary-card.warn::before, .summary-card.ready::before, .summary-card.stock::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
}
.summary-card.overdue::before, .summary-card.risk::before, .summary-card.bad::before { background: var(--critical); }
.summary-card.warn::before { background: var(--warning); }
.summary-card.ready::before { background: var(--good); }
.summary-card.stock::before { background: var(--accent); }
.summary-card.overdue .num, .summary-card.risk .num, .summary-card.bad .num { color: var(--crit-text); }
.summary-card.warn .num { color: var(--warn-text); }
.summary-card.ready .num { color: var(--good-text); }
.summary-card.stock .num { color: var(--accent-ink); }

.toolbar { background: transparent; border: 0; border-radius: 0; padding: 0; gap: var(--s2); }
.toolbar input[type=text], .toolbar select { background: var(--surface); border-color: var(--hairline); border-radius: var(--radius-sm); }

.table-wrap {
  background-color: var(--surface);
  border-color: var(--hairline);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  background-image:
    linear-gradient(to right, var(--surface) 30%, transparent),
    linear-gradient(to right, transparent, var(--surface) 70%),
    linear-gradient(to right, rgba(17,17,17,0.10), rgba(17,17,17,0)),
    linear-gradient(to left, rgba(17,17,17,0.10), rgba(17,17,17,0));
}
.table-wrap.flat-scroll { background-image: none; }
th { background: var(--surface); color: var(--muted); letter-spacing: .06em; border-bottom: 1px solid var(--hairline); }
th:hover { color: var(--ink); background: var(--surface); }
td { border-bottom-color: var(--hairline-2); }

.badge { gap: 5px; padding: 2px 9px; font-weight: 700; line-height: 1.6; box-shadow: none; }
.badge::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex-shrink: 0; }

/* ===========================================================================
   MODERN DASHBOARD LAYER (2026-10-04, owner: "what about the design? can you make it advance"
   -> every page at once, "modern dashboard": cards with clear headings, colour only for what
   needs action, softer layered shadows, more air, cleaner type).
   LOOK ONLY: no markup, menu, data or wording changes. It sits last so it wins over the rules
   above, and `body` raises it over the pages' own <style> blocks (My Day, Team KPIs, Approvals,
   Gorgias...), which load after this file. design-tokens.css is NOT touched (Forward Inventory
   shares it): the few values only this app needs are new --ffm-* names, light and dark.
   =========================================================================== */
:root {
  --ffm-page: #f3f5f8;                 /* a cool grey page, so white cards stand off it */
  --ffm-sidebar: #ffffff;
  --ffm-card-shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 8px rgba(16, 24, 40, .04);
  --ffm-card-lift: 0 2px 4px rgba(16, 24, 40, .06), 0 10px 24px rgba(16, 24, 40, .08);
  --ffm-radius: 14px;
  --ffm-brand: linear-gradient(135deg, #2e6ee0 0%, #6a5cf0 100%);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --ffm-page: var(--bg); --ffm-sidebar: var(--sidebar-bg); --ffm-card-shadow: var(--shadow); --ffm-card-lift: var(--shadow-lift); }
}
:root[data-theme="dark"] { --ffm-page: var(--bg); --ffm-sidebar: var(--sidebar-bg); --ffm-card-shadow: var(--shadow); --ffm-card-lift: var(--shadow-lift); }

body { background: var(--ffm-page); font-feature-settings: 'cv11', 'ss01', 'tnum'; letter-spacing: -.003em; }
body h1, body h2, body h3 { letter-spacing: -.015em; }

/* ---- sidebar: white rail, brand mark, an accent bar on the open page ---- */
body .sidebar { background: var(--ffm-sidebar); border-right: 1px solid var(--hairline); }
body .sidebar-brand { padding: 20px 18px 14px; letter-spacing: 0; font-size: 14px; }
body .sidebar-brand-icon { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 9px; background: var(--ffm-brand); color: #fff; font-size: 16px; box-shadow: 0 2px 6px rgba(46, 110, 224, .35); }
body .sidebar-brand-icon svg { stroke: #fff; }
body .nav-section { font-size: 10.5px; letter-spacing: .1em; color: var(--muted); opacity: .85; padding: 18px 12px 6px; }
body .nav-item { position: relative; padding: 8px 12px; border-radius: 9px; font-weight: 500; color: var(--sidebar-ink); }
body .nav-item:hover { background: var(--sidebar-hover); color: var(--ink); }
body .nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
body .nav-item.active::before { content: ''; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
body .nav-item b[data-count] { margin-left: auto !important; font-variant-numeric: tabular-nums; }

/* ---- top bar: quiet, glassy, no heavy rule ---- */
body .topbar { background: color-mix(in srgb, var(--ffm-page) 82%, transparent); border-bottom: 1px solid var(--hairline); box-shadow: none; padding-bottom: 12px; margin-bottom: 22px; }

/* ---- type ---- */
body .page-title, body .dr-date, body .k-top h1 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
body .page-head-meta, body .k-intro, body .dr-sub, body .dr-day-left { color: var(--muted); }

/* ---- buttons: one height, softer corners, a lift on hover ---- */
body .btn { border-radius: 9px; min-height: 34px; padding: 7px 14px; font-weight: 600; border-color: var(--hairline); background: var(--surface); box-shadow: 0 1px 2px rgba(16, 24, 40, .05); }
body .btn:hover { border-color: var(--border-strong); background: var(--surface); box-shadow: var(--ffm-card-shadow); }
body .btn-primary { background: var(--accent); border-color: transparent; color: #fff; box-shadow: 0 1px 2px rgba(16, 24, 40, .08), inset 0 1px 0 rgba(255, 255, 255, .15); }
body .btn-primary:hover { background: var(--accent-hover); color: #fff; border-color: transparent; }
body .btn-ghost { background: var(--surface); }
body .btn-danger { background: var(--surface); }

/* ---- inputs ---- */
body input:not([type=checkbox]):not([type=radio]):not([type=range]), body select, body textarea { border-radius: 9px; border-color: var(--hairline); }
body input:focus, body select:focus, body textarea:focus { border-color: var(--accent); box-shadow: var(--ring); outline: none; }

/* ---- cards: every boxed block on every page reads as one family ---- */
body .summary-card, body .table-wrap, body .k-person, body .k-tile, body .k-box, body .k-today,
body .dr-ml, body .dr-hww, body .dr-out, body .dr-checkin, body .dr-back, body .dr-dates, body .dr-block,
body .dr-team-card, body .modal {
  border-radius: var(--ffm-radius); border-color: var(--hairline); box-shadow: var(--ffm-card-shadow); background-color: var(--surface);
}
body .summary-card.clickable:hover, body .dr-team-card:hover { box-shadow: var(--ffm-card-lift); }
body .summary-card .num, body .k-val, body .dr-score-n { font-variant-numeric: tabular-nums; letter-spacing: -.025em; }
body .k-tile { padding: 14px 16px 14px 15px; }
body .k-tile::before { width: 4px; border-radius: 0 4px 4px 0; top: 12px; bottom: 12px; }
body .k-person h2 { font-size: 20px; }

/* ---- folds: a turning chevron instead of the browser's triangle ---- */
body details > summary { list-style: none; cursor: pointer; }
body details > summary::-webkit-details-marker { display: none; }
body details > summary::before {
  content: ''; display: inline-block; width: 6px; height: 6px; margin: 0 10px 2px 2px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); opacity: .5; transition: transform .15s ease;
}
body details[open] > summary::before { transform: rotate(45deg); margin-bottom: 4px; }
body .dr-tools > details > summary::before, body #dr-ml-forms details > summary::before { margin-right: 7px; }

/* ---- tables ---- */
body th { font-size: 11px; font-weight: 600; letter-spacing: .06em; background: var(--surface-2); }
body tbody tr { transition: background-color .1s ease; }
body tbody tr:hover { background: var(--surface-2); }

/* ---- pills and chips ---- */
body .badge, body .k-pill, body .dr-ml-tag, body .dr-chip { border-radius: 999px; }
body .dr-ml-chip { border-radius: 999px; font-weight: 500; }
body .dr-ml-chip:hover { border-color: var(--border-strong); }

/* ---- My Day: the list is the hero ---- */
body .dr-ml { padding: 16px 18px; }
body .dr-ml h2 { font-size: 18px; }
body .dr-ml-item { border-left: 0; border-radius: 9px; padding: 7px 10px; margin: 2px 0; }
body .dr-ml-item:hover { background: var(--surface-2); }
body .dr-ml-item a { font-weight: 600; text-decoration: none; color: var(--accent-ink); }
body .dr-ml-item a:hover { text-decoration: underline; }
body .dr-ml details { border-top-color: var(--hairline-2); }

/* ---- segmented controls (Team KPIs period, view buttons) ---- */
body .k-period { border-radius: 10px; padding: 3px; background: var(--surface-2); border: 1px solid var(--hairline); gap: 2px; }
body .k-period button { border-radius: 7px; border: 0; }
body #relatedViews .btn { border-radius: 999px; }

/* Things that pin to the top while a long table scrolls carry the page colour, or they show as a
   pale strip on the new grey page. Ordinary buttons stay medium weight; the primary one is bold. */
body .summary.sticky-summary, body .table-wrap.sticky-matrix, body .toolbar.sticky-toolbar { background: var(--ffm-page); }
body .btn { font-weight: 500; }
body .btn-primary { font-weight: 600; }
body #relatedViews .btn, body .btn { text-decoration: none; }
