table tr.amending-row td {
  background-color: #FFFACD !important;
  border-top: 2px solid #FFD700;
  border-bottom: 2px solid #FFD700;
  transition: background-color 0.3s ease;
}

.selected-row {
  background-color: #d0ebff; /* Light blue */
}

/* ==========================================================================
   Dark theme for the highlight rules in this file.

   Each of them sets a pale background and leaves the text colour to inherit,
   which is fine while the inherited colour is dark. Under the dark theme the
   text goes light and pale-on-light becomes unreadable, so these need real
   dark equivalents rather than being left to inherit. Toggled by
   data-bs-theme on <html> - see public/js/theme.js.
   ========================================================================== */
[data-bs-theme='dark'] table tr.amending-row td {
  background-color: #4a4423 !important;
  border-top-color: #8a7420;
  border-bottom-color: #8a7420;
  color: #f8f9fa;
}

[data-bs-theme='dark'] .selected-row {
  background-color: #24405c;
  color: #f8f9fa;
}

[data-bs-theme='dark'] td.highlight {
  background-color: #5c5320;
  color: #f8f9fa;
}

[data-bs-theme='dark'] td.row-highlight {
  background-color: #1f4a5c;
  color: #f8f9fa;
}

[data-bs-theme='dark'] #msa-analysis-bms-table thead th,
[data-bs-theme='dark'] .scroll-table thead th,
[data-bs-theme='dark'] .scroll-table-fh thead th {
  background: #2b3035;
}

[data-bs-theme='dark'] .custom-scroll-container::-webkit-scrollbar-thumb {
  background-color: #4a5158;
}

/* .text-primary keeps its light-theme blue, which is too dim on a dark
   navbar - lift the nav links to the emphasis blue instead. */
[data-bs-theme='dark'] .navbar .nav-link.text-primary {
  color: #6ea8fe !important;
}

.table-wrapper {
  max-height: 50vh;      /* limit to half the viewport height */
  overflow-y: auto;      /* scroll if content exceeds */
}

#msa-analysis-bms-table thead th {
  position: sticky;
  top: 0;
  background: #f8f9fa;   /* Bootstrap light background */
  z-index: 2;            /* keep above body cells */
}

.table td.currency-cell,
.table th.currency-cell {
  white-space: nowrap;       /* prevents wrapping */
  width: 110px;              /* or whatever width fits */
}

.scroll-table {
  max-height: 50vh;       /* limit to half the viewport height */
  overflow-y: auto;       /* vertical scroll if content exceeds */
}

/* sticky header inside scrollable wrapper */
.scroll-table thead th {
  position: sticky;
  top: 0;
  background: #f8f9fa;    /* Bootstrap light background */
  z-index: 2;             /* keep header above body cells */
}

.scroll-table-fh {
  max-height: 75vh;
  overflow-y: auto;
}
.scroll-table-fh thead th {
  position: sticky;
  top: 0;
  background: #f8f9fa;    /* Bootstrap light background */
  z-index: 2;             /* keep header above body cells */
}



td.highlight {
  background-color: yellow;
  transition: background-color 0.3s ease;
}

td.row-highlight {
  background-color: lightblue;
  transition: background-color 0.3s ease;
}

/* 1. Hide the "ON" icon by default */
.icon-on {
    display: none !important;
}

/* 2. When the checkbox is CHECKED: */

/* Hide the "OFF" icon */
.row-delete-check:checked + label .icon-off {
    display: none !important;
}

/* Show the "ON" icon */
.row-delete-check:checked + label .icon-on {
    display: inline-block !important;
}

/* 3. Keep your row highlighting logic */
/* Highlight the whole row red */
tr:has(.row-delete-check:checked) {
    background-color: rgba(220, 53, 69, 0.08) !important;
    color: #dc3545; /* Optional: turn the text dim red too */
    transition: all 0.2s;
}

/* Apply strikethrough to the cells when checked */
tr:has(.row-delete-check:checked) td {
    text-decoration: line-through;
    text-decoration-color: #dc3545; /* Makes the line red */
    opacity: 0.6; /* Makes the deleted line look 'faded' */
}

/* EXCEPT the first cell (the checkbox) so it stays readable */
tr:has(.row-delete-check:checked) td:first-child {
    text-decoration: none;
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing !important;
}

.drag-handle:hover i {
    color: #0d6efd !important; /* Turns blue when hovered */
}

.modal.hide .btn-close {
  pointer-events: none;
}

/* Keeps the dropdown list contained with a clean scroll bar */
  .custom-scroll-container {
    max-height: 220px; 
    overflow-y: auto;
    padding-right: 5px;
  }

  /* Extends click target for easier selection */
  .cursor-pointer {
    cursor: pointer;
  }

  /* Custom styling for standard webkit scrollbars (optional but matches production styles) */
  .custom-scroll-container::-webkit-scrollbar {
    width: 6px;
  }
  .custom-scroll-container::-webkit-scrollbar-thumb {
    background-color: #dbdbdb;
    border-radius: 4px;
  }

/* ==========================================================================
   Stock Checker (Stock Tools) - the web replacement for Stock_Checker.accdb.
   The .sc-* classes are only used by that page.
   Colours are Bootstrap's own greys/accents so the page matches the app.

   Every colour used below is a token declared here, and the dark theme
   redefines only these tokens - so nothing further down the file needs a
   light/dark variant of its own.
   ========================================================================== */
#stock_checker {
  --sc-surface: #ffffff;
  --sc-sunken: #f8f9fa;
  --sc-border: #dee2e6;
  --sc-border-soft: #e9ecef;
  --sc-ink: #212529;
  --sc-ink-secondary: #495057;
  --sc-ink-muted: #6c757d;
  --sc-accent: #0d6efd;
  --sc-row-hover: #f1f5fd;
  --sc-row-current: #e7f1ff;
  --sc-head-hover: #eef2f7;
  --sc-empty-ink: #adb5bd;
  --sc-icon-ink: #ced4da;
  --sc-scroll-thumb: #dbdbdb;
  --sc-exclude-bg: #fffdf6;
  --sc-exclude-border: #f0c36d;
  --sc-exclude-border-focus: #e0a800;
  --sc-exclude-ring: rgba(224, 168, 0, 0.15);
}

/* Dark theme. Note the surface/sunken relationship is kept, not inverted: a
   panel surface stays one step lighter than the ground it sits on, which is
   what reads as raised in either theme. */
[data-bs-theme='dark'] #stock_checker {
  --sc-surface: #2f3438;
  --sc-sunken: #26292e;
  --sc-border: #454c54;
  --sc-border-soft: #383e45;
  --sc-ink: #e9ecef;
  --sc-ink-secondary: #adb5bd;
  --sc-ink-muted: #8b949e;
  --sc-accent: #6ea8fe;
  --sc-row-hover: #363d45;
  --sc-row-current: #2c3b4d;
  --sc-head-hover: #333940;
  --sc-empty-ink: #6c757d;
  --sc-icon-ink: #495057;
  --sc-scroll-thumb: #4a5158;
  --sc-exclude-bg: #2e2a1d;
  --sc-exclude-border: #8a6f2a;
  --sc-exclude-border-focus: #b8912f;
  --sc-exclude-ring: rgba(184, 145, 47, 0.25);
}

/* ---------- Search bar: stays put while you scroll the results ---------- */
.sc-searchbar {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--sc-surface);
  border-bottom: 1px solid var(--sc-border);
  padding: 0.875rem 1rem;
}

.sc-searchbar .form-control,
.sc-searchbar .btn {
  height: 40px;
}

/* ---------- Find-by-description strip, under the search bar ---------- */
.sc-finder {
  background: var(--sc-sunken);
  border-bottom: 1px solid var(--sc-border);
  padding: 0.75rem 1rem 0.875rem;
}

/* Exclusion terms get a warm tint so they don't read as another include box.
   Used by the page finder and the Stock List modal, so not scoped to either. */
.sc-exclude {
  border-color: var(--sc-exclude-border);
  background: var(--sc-exclude-bg);
  color: var(--sc-ink);
}

.sc-exclude:focus {
  background: var(--sc-exclude-bg);
  color: var(--sc-ink);
  border-color: var(--sc-exclude-border-focus);
  box-shadow: 0 0 0 0.2rem var(--sc-exclude-ring);
}

/* ---------- Section headings ---------- */
.sc-section-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sc-ink-muted);
  margin-bottom: 0.5rem;
}

/* Part numbers are compared character by character - give them a mono face
   and stop them wrapping mid-code. */
.sc-pn {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125rem;
  white-space: nowrap;
}

/* ---------- Selected part header ---------- */
.sc-part-header {
  background: var(--sc-sunken);
  border: 1px solid var(--sc-border);
  border-radius: 0.5rem;
  padding: 1rem 1.25rem;
}

.sc-part-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--sc-ink);
  line-height: 1.2;
}

.sc-part-desc {
  color: var(--sc-ink-secondary);
  font-size: 0.9375rem;
  margin-top: 0.25rem;
}

/* ---------- KPI tiles: label above, value below ---------- */
.sc-kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.sc-kpi {
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
}

.sc-kpi-label {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sc-ink-muted);
}

/* Standalone figures keep the font's proportional digits - tabular-nums is
   for columns that have to line up, not for display-size numbers. */
.sc-kpi-value {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--sc-ink);
  line-height: 1.25;
  margin-top: 0.125rem;
}

/* Free stock is the number people come to this page for. */
.sc-kpi-lead {
  border-color: var(--sc-accent);
  box-shadow: inset 3px 0 0 var(--sc-accent);
}

.sc-kpi-lead .sc-kpi-value {
  font-size: 1.75rem;
}

.sc-kpi-value.sc-zero {
  color: var(--sc-ink-muted);
  font-weight: 500;
}

/* ---------- Field tables (pricing, classification) ---------- */
.sc-fields {
  width: 100%;
  font-size: 0.875rem;
}

.sc-fields th,
.sc-fields td {
  padding: 0.375rem 0;
  border-bottom: 1px solid var(--sc-border-soft);
  vertical-align: baseline;
}

.sc-fields tr:last-child th,
.sc-fields tr:last-child td {
  border-bottom: 0;
}

.sc-fields th {
  font-weight: 500;
  color: var(--sc-ink-muted);
  white-space: nowrap;
}

.sc-fields td {
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--sc-ink);
}

.sc-fields td.sc-empty {
  color: var(--sc-empty-ink);
}

/* A zero price is real data, not a blank - keep it readable but quiet so the
   prices that are actually set are the ones that catch the eye. */
.sc-fields td.sc-quiet {
  color: var(--sc-ink-muted);
  font-weight: 400;
}

/* ---------- Data grids ---------- */
.sc-grid {
  border: 1px solid var(--sc-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.sc-grid-scroll {
  max-height: 260px;
  overflow-y: auto;
}

/* Measured against table-sm at the app's base font size: the sticky header is
   25px and a row carrying a copy button is 32.3px (a plain text row is 28.5px -
   the button sets the height). Kept as tokens so a row count reads as a row
   count rather than a magic pixel value. Re-measure if the row gains controls. */
.sc-grid {
  --sc-head-h: 25px;
  --sc-row-h: 32.3px;
}

/* Five rows deep, scroll for the rest. */
.sc-grid-scroll-5 {
  max-height: calc(var(--sc-head-h) + 5 * var(--sc-row-h));
}

.sc-grid table {
  margin-bottom: 0;
  font-size: 0.8125rem;
}

.sc-grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--sc-sunken);
  border-bottom: 1px solid var(--sc-border);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--sc-ink-muted);
  white-space: nowrap;
}

.sc-grid td {
  font-variant-numeric: tabular-nums;
  vertical-align: middle;
}

.sc-grid tbody tr:hover {
  background: var(--sc-row-hover);
}

.sc-grid tbody tr.sc-selectable {
  cursor: pointer;
}

/* The current part, when it appears in one of the grids. */
.sc-grid tbody tr.sc-current {
  background: var(--sc-row-current);
  box-shadow: inset 3px 0 0 var(--sc-accent);
}

/* ---------- Sortable column headers ---------- */
.sc-grid thead th.sc-sortable {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.sc-grid thead th.sc-sortable:hover {
  color: var(--sc-ink);
  background: var(--sc-head-hover);
}

/* The caret only appears on the column actually in use, so the header row
   doesn't turn into a row of arrows. */
.sc-grid thead th.sc-sortable::after {
  content: '';
  display: inline-block;
  width: 0.75em;
}

.sc-grid thead th.sc-sortable[data-active='asc']::after {
  content: '\2191';
  color: var(--sc-accent);
}

.sc-grid thead th.sc-sortable[data-active='desc']::after {
  content: '\2193';
  color: var(--sc-accent);
}

.sc-grid thead th.sc-sortable[data-active] {
  color: var(--sc-accent);
}

.sc-grid-empty {
  padding: 1rem;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--sc-ink-muted);
}

/* ---------- Notes ---------- */
.sc-notes {
  background: var(--sc-sunken);
  border: 1px solid var(--sc-border);
  border-radius: 0.5rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.8125rem;
  color: var(--sc-ink-secondary);
  white-space: pre-wrap;
  min-height: 96px;
  max-height: 220px;
  overflow-y: auto;
  margin-bottom: 0;
}

/* ---------- Empty / loading states ---------- */

/* Nothing-found panel. Same shape as the placeholder, but it is an offer to do
   something rather than a dead end, so it gets a surface and a border to read
   as actionable. */
.sc-nomatch {
  padding: 2.25rem 1rem;
  text-align: center;
  color: var(--sc-ink-secondary);
  background: var(--sc-sunken);
  border: 1px solid var(--sc-border);
  border-radius: 0.5rem;
}

.sc-nomatch .bi {
  font-size: 1.75rem;
  color: var(--sc-icon-ink);
  display: block;
  margin-bottom: 0.5rem;
}

.sc-placeholder {
  padding: 3.5rem 1rem;
  text-align: center;
  color: var(--sc-ink-muted);
}

.sc-placeholder .bi {
  font-size: 2rem;
  color: var(--sc-icon-ink);
  display: block;
  margin-bottom: 0.5rem;
}

.sc-results.sc-loading {
  opacity: 0.45;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

/* Slimmer scrollbars inside the grids, matching custom-scroll-container. */
.sc-grid-scroll::-webkit-scrollbar,
.sc-notes::-webkit-scrollbar {
  width: 6px;
}

.sc-grid-scroll::-webkit-scrollbar-thumb,
.sc-notes::-webkit-scrollbar-thumb {
  background-color: var(--sc-scroll-thumb);
  border-radius: 4px;
}

/* ---------- Resizable grids ---------- */
/* Opting a grid in swaps the fixed five-row cap for a variable one. Written as
   a separate, more specific rule rather than an edit to .sc-grid-scroll-5 so
   the default and the resizable case keep sharing one piece of maths - the row
   tokens above stay the only place a height is calculated. */
.sc-grid-resizable .sc-grid-scroll-5 {
  max-height: calc(var(--sc-head-h) + var(--sc-rows, 5) * var(--sc-row-h));
}

.sc-grid-resize {
  height: 9px;
  cursor: ns-resize;
  background: var(--sc-sunken);
  border-top: 1px solid var(--sc-border);
  /* The handle is the drag surface, so the browser must not claim the gesture
     for scrolling on a touch device. */
  touch-action: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Grip, so the bar reads as draggable rather than as a stray border. */
.sc-grid-resize::after {
  content: '';
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background: var(--sc-scroll-thumb);
}

.sc-grid-resize:hover::after,
.sc-grid-resizing .sc-grid-resize::after {
  background: var(--sc-ink-muted);
}

.sc-grid-resize:focus-visible {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: -2px;
}

/* Text selection during a drag makes the whole grid flash blue as the pointer
   sweeps over it. */
.sc-grid-resizing {
  user-select: none;
}

/* ---------- Incoming stock ---------- */
/* The expected-date cell carries a date plus how far off it is, which wraps
   at the default width and makes rows uneven - the grid caps its height in
   whole rows, so a wrapped row throws that off. */
.sc-incoming td:last-child,
.sc-incoming th:last-child {
  white-space: nowrap;
}

/* ---------- Part image ---------- */
/* Fixed box with the image contained rather than cropped: these come from
   three different webstores and are not a consistent aspect ratio, and a
   cropped product shot can hide the thing that distinguishes one variant
   from another. */
.sc-part-image {
  flex: 0 0 auto;
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  background: var(--sc-surface);
  border: 1px solid var(--sc-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.sc-part-image img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.sc-part-image:hover {
  border-color: var(--sc-accent);
}


/* ---------------------------------------------------------------------------
   Stock Checker - what our distributors have
   Drawn only when something matched, so it never sits there saying nothing.
   The matched-as chip matters most: where their code is not identical to ours
   the panel says so, rather than implying the price belongs to the part on
   screen.
   --------------------------------------------------------------------------- */
.sc-elsewhere {
  border: 1px solid var(--bs-border-color);
  border-radius: .5rem;
  overflow: hidden;
}
.sc-elsewhere-head {
  display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  padding: .5rem .75rem;
  background: var(--bs-tertiary-bg);
  border-bottom: 1px solid var(--bs-border-color);
}
.sc-elsewhere table { width: 100%; margin: 0; font-size: .875rem; }
.sc-elsewhere th, .sc-elsewhere td { padding: .45rem .75rem; white-space: nowrap; }
.sc-elsewhere thead th {
  font-size: .6875rem; text-transform: uppercase; letter-spacing: .06em;
  color: var(--bs-secondary-color); font-weight: 600;
  border-bottom: 1px solid var(--bs-border-color);
}
.sc-elsewhere tbody tr + tr td { border-top: 1px solid var(--bs-border-color); }
.sc-elsewhere .num { text-align: right; font-variant-numeric: tabular-nums; }

.sc-matched-as {
  display: inline-flex; align-items: center; gap: .25rem;
  font-size: .75rem; line-height: 1.3;
  color: var(--bs-warning-text-emphasis);
  background: var(--bs-warning-bg-subtle);
  border: 1px solid var(--bs-warning-border-subtle);
  border-radius: .25rem; padding: .05rem .35rem; margin-left: .4rem;
}
/* Cheaper than our own cost - the row worth acting on. */
.sc-cheaper { color: var(--bs-danger-text-emphasis); font-weight: 600; }
.sc-asof { font-size: .75rem; color: var(--bs-secondary-color); }

/* How old THIS distributor's price is, shown only when it is old enough to
   matter. Sources do not refresh together - the scraped ones are daily, but
   Technoworld's workbook is maintained by hand and lands about weekly, so two
   rows side by side can be a week apart. Muted, not a warning: an old price is
   still worth seeing, it just must not pass for a current one. */
.sc-price-age {
  font-size: .75rem; color: var(--bs-secondary-color);
  margin-left: .4rem; white-space: nowrap;
}

/* The Elsewhere column in the matches grid. A price that came from a code
   that is not quite ours is underlined rather than left looking like an
   ordinary figure - the tooltip then says which code it was. */
.sc-elsewhere-cell.sc-elsewhere-near {
  text-decoration: underline dotted;
  text-underline-offset: .2em;
  cursor: help;
}

/* The hamburger button of the mobile navbar: Bootstrap draws its lines dark, which vanish on the dark theme. */
[data-bs-theme='dark'] .navbar .navbar-toggler-icon { filter: invert(1); }
.navbar .navbar-toggler { --bs-navbar-toggler-border-color: var(--bs-border-color); }
