/* ============================================================================
   GAC Planning — module-specific components (ported from PAC Basic Planning).

   Linked THIRD, after design-tokens.css + app-shell.css. Everything here builds
   on the tokens; the shared chrome (title row, tab row, toolbar, buttons,
   inputs, table) comes from app-shell.css and is consumed as-is, never
   restyled. This file adds only what the shell doesn't ship: the sticky header
   wrapper, the full-height planning layout, the shadcn dropdown + calendar, the
   frozen-pane planning grid, peeks, modals and the PO wizard.
   See design-reference/DESIGN.md.
   ============================================================================ */

/* Slim custom scrollbars app-wide. */
* { scrollbar-width: thin; scrollbar-color: var(--color-border) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: var(--color-border); border-radius: var(--radius-pill); }
*::-webkit-scrollbar-track { background: transparent; }

/* ---- Full-height planning page ------------------------------------------ */
/* The grid scrolls inside .grid-scroll (frozen panes), so the page itself is a
   fixed-viewport flex column: header, banners, toolbar, then the body fills. */
.content.plan-page {
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}
.plan-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* ---- Sticky header (module owns the whole page) --------------------------- */
.app-header {
  position: sticky; top: 0; z-index: 30;
  background: var(--color-bg);
  padding-top: var(--space-4);
  margin-top: calc(-1 * var(--space-4));   /* sit flush under the viewport top */
  flex: none;
}
/* The tab row lives inside .app-header (not a direct child of .content), so the
   shell's full-bleed underline rule doesn't reach it: replicate it here. */
.app-header .tab-row {
  margin-left: calc(-1 * var(--space-8));
  margin-right: calc(-1 * var(--space-8));
  padding-left: var(--space-8);
  padding-right: var(--space-8);
  margin-bottom: var(--space-4);
  scrollbar-width: none;         /* still scrollable, no visible bar */
}
.app-header .tab-row::-webkit-scrollbar { display: none; }
.icon-ghost[disabled] { opacity: 0.4; cursor: default; }
.icon-ghost.is-spinning .icon { animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Saved-view tab extras (the .tab itself is the shell's). */
.tab .icon-star { /* default-view marker (smaller than the leading icon) */
  width: 12px;
  height: 12px;
  color: var(--color-accent);
}
.tab--add { font-weight: var(--fw-regular); color: var(--color-label); }
.tab .dirty-dot { color: var(--color-accent); margin-left: var(--space-1); }

/* ---- Demo-mode / info banner ------------------------------------------- */
.banner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-3);
  padding: var(--space-2) var(--space-3);
  background: var(--banner-bg);
  border: 1px solid var(--banner-border);
  border-radius: var(--radius-card);
  color: var(--banner-text);
  font-size: var(--fs-sm);
}
.banner a { color: var(--banner-link); text-decoration: underline; }

/* ---- Toolbar extras (the .toolbar row itself is the shell's) ------------- */
.content.plan-page > .toolbar { flex-wrap: wrap; justify-content: flex-start; gap: var(--space-2); flex: none; }

.field-label {
  font-size: var(--fs-sm);
  color: var(--color-label);
  margin-right: var(--space-1);
}

/* Live search box: shell .input/.search plus a leading icon and a clear (x). */
.search-wrap { position: relative; display: inline-flex; align-items: center; }
.search-wrap .search { width: 168px; padding-left: 30px; padding-right: 28px; }
.search-wrap .search-lead {
  position: absolute; left: 9px; width: 15px; height: 15px;
  color: var(--color-muted); pointer-events: none;
}
.search-clear {
  position: absolute; right: 4px;
  appearance: none; border: none; background: none; cursor: pointer;
  width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-input); color: var(--color-muted);
}
.search-clear:hover { background: var(--color-hover); color: var(--color-text); }
.search-clear[hidden], .cal-link[hidden] { display: none; }
.search-clear .icon { width: 14px; height: 14px; }

/* ---- shadcn-style checkbox (app-wide; golden rule 5) ---------------------- */
/* The native input stays (keyboard + forms) but draws nothing of its own: a
   16px rounded square, filled with the primary color + a check when on, a dash
   when indeterminate (the picker's partial select-all). */
/* Zero-specificity reset so component rules (e.g. .q-check's margin) win. */
:where(input[type="checkbox"]) { margin: 0; }
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 16px;
  height: 16px;
  display: inline-grid;
  place-content: center;
  vertical-align: middle;
  border: 1px solid var(--color-muted);
  border-radius: 4px;
  background: var(--color-bg);
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
input[type="checkbox"]::before {
  content: "";
  width: 12px;
  height: 12px;
  background: var(--btn-primary-text);
  transform: scale(0);
  transition: transform 0.1s ease;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='3.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center / contain no-repeat;
}
input[type="checkbox"]:checked,
input[type="checkbox"]:indeterminate {
  background: var(--btn-primary-bg);
  border-color: var(--btn-primary-bg);
}
input[type="checkbox"]:checked::before { transform: scale(1); }
input[type="checkbox"]:indeterminate::before {
  transform: scale(1);
  width: 8px;
  height: 2px;
  border-radius: 1px;
  -webkit-mask: none;
          mask: none;
}
input[type="checkbox"]:hover:not(:disabled):not(:checked):not(:indeterminate) { border-color: var(--color-label); }
input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 25%, transparent);
}
input[type="checkbox"]:disabled { opacity: 0.5; cursor: default; }

/* Shared focus ring for the shell inputs (DESIGN.md form-control spec). */
.input:focus, .search:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
}

/* ---- shadcn-style Select + date field (DESIGN.md golden rule 5) ----------- */
/* customSelect() / dateField() in app.js: the field-shell trigger opens a
   token-built popover; there is no native <select> popup or OS date widget. */
.cselect { position: relative; display: inline-block; min-width: 0; }
.cselect--bucket { width: 110px; }
.dfield { width: 132px; }
.fc-format .cselect, .settings-group .cselect, .pw-po-shipto .cselect { display: block; width: 100%; }
.fc-clear-row .dfield { flex: 1 1 auto; width: auto; }
.cselect-trigger {
  width: 100%;
  height: var(--control-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-2);
  font: inherit;
  font-size: var(--fs-base);
  text-align: left;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  cursor: pointer;
}
.cselect-trigger:hover { border-color: var(--color-muted); }
.cselect-trigger[disabled] { opacity: 0.6; cursor: default; }
.cselect-label.is-placeholder { color: var(--color-muted); }
.cselect-trigger[aria-expanded="true"], .cselect-trigger:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
}
.cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-caret { flex: none; color: var(--color-muted); transition: transform 0.15s ease; }
.cselect-trigger[aria-expanded="true"] .cselect-caret { transform: rotate(180deg); }
.cselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 60;
  min-width: 100%;
  width: max-content;
  max-width: 360px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
  max-height: 260px;
  overflow-y: auto;
}
.cselect-opt {
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border: none;
  background: none;
  border-radius: var(--radius-input);
  font: inherit;
  font-size: var(--fs-base);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}
.cselect-opt:hover, .cselect-opt.is-active { background: var(--color-hover); }
.cselect-opt.is-selected { font-weight: var(--fw-medium); }
.cselect-check { flex: none; color: var(--color-accent); visibility: hidden; }
.cselect-opt.is-selected .cselect-check { visibility: visible; }

.cselect-menu.cal { width: 252px; max-height: none; padding: var(--space-2); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-2); }
.cal-title { font-size: var(--fs-base); font-weight: var(--fw-medium); }
.cal-nav {
  appearance: none; border: 1px solid var(--color-border); background: var(--color-bg); cursor: pointer;
  width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-input); color: var(--color-label);
}
.cal-nav:hover { background: var(--color-hover); color: var(--color-text); }
.cal-nav .icon { width: 14px; height: 14px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { text-align: center; font-size: var(--fs-xs); color: var(--color-muted); padding: var(--space-1) 0; }
.cal-day {
  appearance: none; border: none; background: none; cursor: pointer;
  height: 32px; border-radius: var(--radius-input);
  font: inherit; font-size: var(--fs-sm); color: var(--color-text);
  font-variant-numeric: tabular-nums;
}
.cal-day:hover, .cal-day.is-active { background: var(--color-hover); }
.cal-day.is-outside { color: var(--color-muted); }
.cal-day.is-today { box-shadow: inset 0 0 0 1px var(--color-border); }
.cal-day.is-selected, .cal-day.is-selected:hover { background: var(--btn-primary-bg); color: var(--btn-primary-text); }
.cal-foot { display: flex; justify-content: space-between; border-top: 1px solid var(--color-border-faint); margin-top: var(--space-2); padding-top: var(--space-2); }
.cal-link { appearance: none; border: none; background: none; cursor: pointer; font: inherit; font-size: var(--fs-sm); color: var(--color-accent); padding: var(--space-1) var(--space-2); border-radius: var(--radius-input); }
.cal-link:hover { background: var(--color-hover); }

/* ---- Button extras (the .btn family itself is the shell's) --------------- */
/* shadcn "outline" button: white, hairline border, faint shadow. The module's
   default for toolbar / header actions (user choice 2026-10-09). */
.btn--outline {
  background: var(--color-bg);
  color: var(--color-text);
  border-color: var(--color-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.btn--outline:hover:not([disabled]) { background: var(--color-hover); }
.btn--outline:focus-visible {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
}
/* Dropdown trigger: trailing chevron that flips when open. */
.btn--menu { padding-right: var(--space-2); }
.btn--menu .cselect-caret { width: 14px; height: 14px; }
.btn--menu[aria-expanded="true"] .cselect-caret { transform: rotate(180deg); }
.btn--on { background: var(--color-surface-alt); border-color: var(--color-accent); color: var(--color-text); }
.btn--danger {
  background: var(--pill-red-bg);
  border-color: var(--pill-red-text);
  color: var(--pill-red-text);
}
.btn--danger:hover { background: color-mix(in srgb, var(--pill-red-bg) 80%, var(--pill-red-text)); }
.btn[disabled] { opacity: 0.5; cursor: default; }

/* forecast mass-clear block (in the Import forecast peek) */
.fc-clear { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-border-faint); }
.fc-clear-row { display: flex; gap: var(--space-2); align-items: center; margin: var(--space-2) 0; }

/* Segmented control (layout toggle) */
.seg {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-input);
  overflow: hidden;
}
.seg-btn {
  appearance: none;
  border: none;
  background: var(--color-bg);
  height: calc(var(--control-height) - 2px);
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--color-label);
  cursor: pointer;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--color-border); }
.seg-btn.active {
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-weight: var(--fw-medium);
}

/* Checkbox-style toggle (exceptions only) */
label.toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
  padding: 0 var(--space-1);
}
label.toggle .toggle-sub { font-weight: var(--fw-regular); color: var(--color-muted); font-size: var(--fs-sm); }

/* ---- Dropdown menus (item / measure pickers) ----------------------------- */
.menu-wrap { position: relative; display: inline-block; }
.menu-panel {
  position: absolute;
  top: calc(var(--control-height) + var(--space-1));
  left: 0;
  z-index: 30;
  min-width: 260px;
  max-height: 340px;
  overflow-y: auto;
  background: var(--color-bg);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
}
/* Measures: shadcn DropdownMenu with checkbox items. */
.menu-panel--measures { min-width: 240px; max-height: 70vh; }
.mm-head { display: flex; align-items: baseline; justify-content: space-between; padding: var(--space-1) var(--space-2); }
.mm-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); }
.mm-count { font-size: var(--fs-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.mm-sep { height: 1px; background: var(--color-border-faint); margin: var(--space-1) calc(-1 * var(--space-1)); }
.mm-item {
  appearance: none; border: none; background: none; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-2); border-radius: var(--radius-input);
  font: inherit; font-size: var(--fs-base); color: var(--color-text); text-align: left;
}
.mm-item.indent { padding-left: var(--space-6); }
.mm-item:hover, .mm-item:focus-visible { background: var(--color-hover); outline: none; }
.mm-item .cselect-check { visibility: hidden; flex: none; }
.mm-item.is-on .cselect-check { visibility: visible; }
.mm-item:not(.is-on) { color: var(--color-label); }
.mm-foot { display: flex; gap: var(--space-1); }
.mm-action {
  appearance: none; border: none; background: none; cursor: pointer; flex: 1;
  padding: 6px var(--space-2); border-radius: var(--radius-input);
  font: inherit; font-size: var(--fs-sm); color: var(--color-label); text-align: center;
}
.mm-action:hover { background: var(--color-hover); color: var(--color-text); }
.menu-panel .menu-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
}
.menu-panel .menu-head input { flex: 1; }
.menu-panel--settings { min-width: 300px; left: auto; right: 0; max-height: none; overflow-y: visible; padding: var(--space-2); } /* right-aligned; sizes to content (no scroll) */
.settings-group { padding: var(--space-1) var(--space-2) var(--space-2); }
.settings-label { font-size: var(--fs-sm); color: var(--color-label); margin-bottom: var(--space-1); }
.settings-hint { font-size: var(--fs-xs); color: var(--color-muted); margin-top: var(--space-1); }
.menu-panel--settings .seg { width: 100%; }
.btn--block { width: 100%; justify-content: center; }
.menu-panel--settings .seg-btn { flex: 1; white-space: nowrap; }
.menu-panel .menu-head--actions {
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-1);
}
.menu-panel .menu-head--actions .menu-action { width: auto; }
.menu-opt {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-input);
  font-size: var(--fs-base);
  cursor: pointer;
}
.menu-opt:hover { background: var(--color-hover); }
.menu-opt.indent { padding-left: var(--space-6); }
.menu-opt .opt-sub { color: var(--color-muted); font-size: var(--fs-sm); }
.menu-empty { padding: var(--space-2); color: var(--color-muted); font-size: var(--fs-sm); }
.menu-action {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--fs-sm);
  color: var(--color-accent);
  padding: var(--space-1) var(--space-2);
  cursor: pointer;
}

/* Context menu (right-click on a tab) */
.ctx-menu {
  position: fixed;
  z-index: 60;
  min-width: 150px;
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
}
.ctx-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: none;
  font: inherit;
  font-size: var(--fs-base);
  color: var(--color-text);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-input);
  cursor: pointer;
}
.ctx-menu button:hover { background: var(--color-hover); }
.ctx-menu button.danger { color: var(--color-danger-text); }

/* ---- Summary strip -------------------------------------------------------- */
.summary {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
.summary .card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3) var(--space-4);
  min-width: 130px;
}
.summary .card .label {
  font-size: var(--fs-sm);
  color: var(--color-label);
  margin-bottom: var(--space-1);
}
.summary .card .value {
  font-size: var(--fs-xl);
  font-weight: var(--fw-semibold);
  color: var(--color-text);
}
.summary .card .value.neg { color: var(--color-danger-text); }

/* ---- Chart ----------------------------------------------------------------- */
.chart-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: var(--space-3);
  margin-bottom: var(--space-4);
  overflow-x: auto;
}
.chart-label { font-size: var(--fs-xs); fill: var(--color-label); }
.chart-zero { stroke: var(--color-border); stroke-width: 1; }
.chart-line { fill: none; stroke-width: 1.5; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding-top: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--color-label);
}
.chart-legend .swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: var(--space-1);
  vertical-align: baseline;
}

/* ---- Planning grid ---------------------------------------------------------- */
/* Frozen panes: the grid scrolls both axes inside .grid-scroll; the bucket
   header row sticks to the top, the item/measure columns stick to the left. */
.grid-scroll {
  flex: 1 1 auto; min-height: 0; overflow: auto;
  /* Full-bleed (golden rule 6): the grid runs to the page edges; the frozen
     label columns pad back to the 32px content inset. */
  margin-left: calc(-1 * var(--space-8));
  margin-right: calc(-1 * var(--space-8));
}
/* Column layout: only the Item column is first (measure rows under a rowspan
   start with the Measure cell, which must NOT get the inset). */
.table--column th.col-item, .table--column td.itemcell { padding-left: var(--space-8); }
/* Grouped layout: the label column is first on every row. */
.table--grouped th.rowlabel, .table--grouped tr.item-head th { padding-left: var(--space-8); }
.table--grouped .measurecell.indent { padding-left: calc(var(--space-8) + var(--space-3)); }
.grid-scroll .table th:last-child, .grid-scroll .table td:last-child { padding-right: var(--space-8); }
.table--column { --itemcol-w: 232px; } /* 200px name + the 32px bleed inset */

.table {
  border-collapse: separate; /* sticky + collapse lose borders in Chrome */
  border-spacing: 0;
  width: 100%;
  font-size: var(--fs-base);
}
/* Natural-width mode: columns size to content and the table anchors left,
   leaving blank space on the right (instead of stretching a few short-range
   columns wide). Toggled by the "Stretch columns to full width" setting. */
.table--natural { width: auto; }
/* Full cell grid comes from the shell (.table th/td border-right + th
   border-top); PAC's "Vertical borders" toggle was dropped in the port. */
.table th, .table td {
  height: var(--row-height);
  padding: 0 var(--space-3);
  border-bottom: 1px solid var(--color-border-faint);
  text-align: right;
  font-weight: var(--fw-regular);
  white-space: nowrap;
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 12;
  background: var(--color-bg);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  color: var(--color-label);
  border-bottom: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border-faint);
}
.table thead th.rowlabel { z-index: 15; } /* corner: above both axes */
/* An open BOM-version dropdown must paint above the next rows' sticky cells. */
.table td.rowlabel:has(.cselect.is-open), .table th.rowlabel:has(.cselect.is-open) { z-index: 20; }
.th-sub { /* Sunday date under the week number */
  display: block;
  font-size: var(--fs-xs);
  font-weight: var(--fw-regular);
  color: var(--color-muted);
}
.table thead th.is-current { color: var(--color-text); background: var(--color-surface-alt); }
.table thead th.is-current .th-sub { color: var(--color-accent); font-weight: var(--fw-medium); }
.bom-arrow { color: var(--color-muted); }
/* Per-item BOM version picker: a compact customSelect inside the item cell. */
.cselect--bomv .cselect-trigger { height: 24px; font-size: var(--fs-sm); color: var(--color-label); max-width: 180px; padding: 0 var(--space-1); }
.cselect--bomv { vertical-align: middle; }
.table th.rowlabel, .table td.rowlabel {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--color-bg);
  z-index: 5;
}
/* Column layout: Item column (width = --itemcol-w) then Measure column offset
   past it by the same var, so the two frozen columns stay aligned in every
   item-column mode (fixed / auto / truncate — see .table--item* below). */

.table--column .itemcell, .table--column thead th.col-item {
  width: var(--itemcol-w);
  min-width: var(--itemcol-w);
  max-width: var(--itemcol-w);
  white-space: normal;
}
.table--column .measurecell, .table--column thead th.col-measure { left: var(--itemcol-w); }

/* Item-column width modes (Settings → "Item column").
   fixed  = 200px, name wraps (default, no extra rules).
   truncate = 200px, name/sub clipped with an ellipsis.
   auto   = column grows to the widest name (JS sets --itemcol-w post-render so
            the Measure column offset follows; clamped 200–480px). */
.table--itemtrunc .itemcell, .table--itemtrunc thead th.col-item { white-space: nowrap; overflow: hidden; }
.table--itemtrunc .itemcell .item-name {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
.table--itemtrunc .itemcell .item-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table--column.table--itemauto .itemcell, .table--column.table--itemauto thead th.col-item {
  width: max-content;
  min-width: 200px;
  max-width: 480px;
  white-space: nowrap;
}
.table--column.table--itemauto .itemcell .item-sub { white-space: nowrap; }
.table--grouped tr.item-head th { position: sticky; left: 0; }
.table .itemcell {
  font-weight: var(--fw-medium);
  color: var(--color-text);
  vertical-align: top;
  padding-top: var(--space-2);
}
.table .itemcell .item-sub {
  display: block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-regular);
  color: var(--color-label);
}
.table .measurecell { color: var(--color-label); font-size: var(--fs-sm); }
.table .measurecell.indent { padding-left: var(--space-6); }

.measure-row.kind-subtotal td, .measure-row.kind-subtotal th.rowlabel { font-weight: var(--fw-medium); }
.measure-row.kind-subtotal th.measurecell { color: var(--color-text); }
.measure-row.m-ending td { font-weight: var(--fw-medium); }
.measure-row.first-of-item td, .measure-row.first-of-item th { border-top: 1px solid var(--color-border); }

/* Grouped layout: an item header row above each measure block */
tr.item-head th {
  text-align: left;
  font-weight: var(--fw-semibold);
  color: var(--color-text);
  border-top: 1px solid var(--color-border);
  background: var(--color-canvas);
}
tr.item-head .item-sub { font-weight: var(--fw-regular); color: var(--color-label); margin-left: var(--space-2); font-size: var(--fs-sm); }

.cell-muted, td.zero { color: var(--color-muted); }
/* Current-week column tint. Kept at the same specificity as (and BEFORE)
   td.neg/td.warn so a stockout/below cell keeps its red/amber in this column. */
td.is-current { background: var(--color-surface-alt); }
td.neg { color: var(--color-danger-text); background: var(--pill-red-bg); }
td.warn { color: var(--pill-amber-text); background: var(--pill-amber-bg); }

/* Cells with source documents behind them open the drill-down pane. */
td.cell-click { cursor: pointer; }
td.cell-click:hover { box-shadow: inset 0 0 0 1px var(--color-border); }

/* Clickable item name (opens the item pane) */
button.item-name {
  appearance: none;
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: var(--fw-medium);
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
}
button.item-name:hover { text-decoration: underline; }

/* Editable cells (forecast / planned) — the input fills the cell so its
   number aligns exactly like the read-only cells. */
td.cell-edit { padding: 0; }
input.cell-input {
  width: 100%;
  min-width: 76px;
  height: 100%;
  padding: 0 var(--space-3);
  font: inherit;
  font-size: var(--fs-base);
  text-align: right;
  color: var(--color-text);
  background: transparent;
  border: none;
  border-radius: 0;
}
input.cell-input:hover { background: var(--color-hover); }
input.cell-input.zero { color: var(--color-muted); } /* match read-only zero weight */
input.cell-input:focus {
  outline: none;
  background: var(--color-bg);
  box-shadow: inset 0 0 0 1px var(--color-accent);
  color: var(--color-text);
}

/* Status pills (exception column) */
.pill {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
}
.pill--blue   { background: var(--pill-blue-bg);   color: var(--pill-blue-text); }
.pill--gray   { background: var(--pill-gray-bg);   color: var(--pill-gray-text); }
.pill--green  { background: var(--pill-green-bg);  color: var(--pill-green-text); }
.pill--red    { background: var(--pill-red-bg);    color: var(--pill-red-text); }
.pill--amber  { background: var(--pill-amber-bg);  color: var(--pill-amber-text); }
.pill--yellow { background: var(--pill-yellow-bg); color: var(--pill-yellow-text); }
.pill--violet { background: var(--pill-violet-bg); color: var(--pill-violet-text); }

/* ---- Forecast import screen -------------------------------------------------- */
.forecast-screen { max-width: 900px; padding-top: var(--space-2); }
.fc-title {
  margin: 0 0 var(--space-1);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}
.fc-sub { margin: 0 0 var(--space-4); color: var(--color-label); font-size: var(--fs-sm); }
.fc-format { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.fc-format .field-label { margin-top: var(--space-2); }
.fc-format .field-label:first-child { margin-top: 0; }
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-card);
  color: var(--color-label);
  text-align: center;
  cursor: pointer;
  margin-bottom: var(--space-4);
}
.dropzone:hover, .dropzone.drag { border-color: var(--color-accent); background: var(--color-hover); }
.dropzone .icon { width: 24px; height: 24px; }
.dropzone .hint { font-size: var(--fs-sm); color: var(--color-muted); }
.forecast-screen .banner { margin: var(--space-3) 0 0; }
/* Sunday-alignment note inside the forecast peek: full width, pushed off the
   Total qty row above it. */
.sp-body .banner.fc-note { margin: var(--space-4) 0 0; }
.fc-unmatched {
  margin-top: var(--space-3);
  padding: var(--space-2) var(--space-3);
  font-size: var(--fs-sm);
  color: var(--pill-amber-text);
  background: var(--pill-amber-bg);
  border-radius: var(--radius-card);
}
.fc-table {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--color-border-faint);
  border-radius: var(--radius-card);
  margin-top: var(--space-3);
}
.fc-actions { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
.summary .card .value--sm { font-size: var(--fs-base); font-weight: var(--fw-medium); }

/* ---- Empty state ------------------------------------------------------------ */
.empty {
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-muted);
}
.empty .hint { font-size: var(--fs-sm); margin-top: var(--space-2); }

/* ---- Error strip -------------------------------------------------------------- */
.error-strip {
  margin-bottom: var(--space-4);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--pill-red-bg);
  background: var(--pill-red-bg);
  color: var(--pill-red-text);
  border-radius: var(--radius-card);
  font-size: var(--fs-sm);
}

/* ---- Drill-down side pane -------------------------------------------------------- */
.side-pane {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
  box-shadow: var(--shadow-md);
  z-index: 40;
}
.side-pane header {
  position: relative;
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border);
}
.sp-title { font-weight: var(--fw-semibold); padding-right: var(--space-6); }
.sp-sub { font-size: var(--fs-sm); color: var(--color-label); margin-top: var(--space-1); }
.sp-close {
  position: absolute;
  top: var(--space-3);
  right: var(--space-3);
  appearance: none;
  border: none;
  background: none;
  font-size: var(--fs-base);
  color: var(--color-label);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-input);
}
.sp-close:hover { background: var(--color-hover); color: var(--color-text); }
.side-pane--wide { width: 460px; }
.sp-body { flex: 1; overflow-y: auto; padding: var(--space-2) var(--space-5); }

/* Item picker peek */
.pk-search { display: flex; gap: var(--space-2); align-items: center; padding-top: var(--space-2); position: sticky; top: 0; background: var(--color-bg); }
.pk-search input { flex: 1; }
.pk-count { font-size: var(--fs-sm); color: var(--color-muted); padding: var(--space-2) 0; }
.pk-list { display: flex; flex-direction: column; }
.pk-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-2);
  align-items: start;
  padding: var(--space-2);
  border-bottom: 1px solid var(--color-border-faint);
  border-radius: var(--radius-input);
  cursor: pointer;
}
.pk-row:hover { background: var(--color-hover); }
.pk-row.on { background: var(--color-surface-alt); }
.pk-row input { margin-top: 2px; }
.pk-text { display: flex; flex-direction: column; min-width: 0; }
.pk-main { font-weight: var(--fw-medium); }
.pk-desc { font-size: var(--fs-sm); color: var(--color-label); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pk-meta { font-size: var(--fs-sm); color: var(--color-muted); }

/* Order queue peek */
.q-group { margin-bottom: var(--space-4); }
.q-vendor {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: var(--fw-semibold); font-size: var(--fs-sm);
  padding: var(--space-2) 0 var(--space-1);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-1);
}
.q-vendor a { color: var(--color-accent); text-decoration: none; font-weight: var(--fw-regular); }
.q-vendor a:hover { text-decoration: underline; }
/* Vendor location (plant) sub-header under the vendor */
.q-location {
  font-size: var(--fs-xs); font-weight: var(--fw-medium); color: var(--color-label);
  padding: var(--space-1) 0 0 var(--space-2); margin-bottom: var(--space-1);
}
/* Stock-out / order-by line under a queued item */
.q-when { font-size: var(--fs-xs); margin-top: 2px; }
.q-stockout { color: var(--color-danger-text); font-weight: var(--fw-medium); }
.q-nostock { color: var(--color-muted); }

/* PO creation wizard — right-docked side panel (left PO mockup, right PO list).
   The backdrop is a transparent full-screen layer so an outside click closes it
   (matching the app's other side panels); the panel itself docks to the right. */
.pw-backdrop { position: fixed; inset: 0; z-index: 100; background: transparent; display: flex; justify-content: flex-end; }
.pw-modal { width: min(1080px, 96vw); height: 100%; display: flex; flex-direction: column; background: var(--color-bg); border-left: 1px solid var(--color-border); box-shadow: var(--shadow-md); overflow: hidden; }
.pw-header { display: flex; align-items: center; justify-content: space-between; padding: var(--space-3) var(--space-5); border-bottom: 1px solid var(--color-border); }
.pw-title { font-weight: var(--fw-semibold); }
.pw-body { flex: 1; display: flex; min-height: 0; }
.pw-left { flex: 1; overflow-y: auto; padding: var(--space-5); background: var(--color-canvas); }
.pw-right { width: 320px; flex: none; display: flex; flex-direction: column; border-left: 1px solid var(--color-border); padding: var(--space-4); min-height: 0; }
.pw-right-title { font-size: var(--fs-sm); font-weight: var(--fw-semibold); color: var(--color-label); margin-bottom: var(--space-2); }
.pw-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.pw-listitem { text-align: left; width: 100%; padding: var(--space-2) var(--space-3); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-input); cursor: pointer; }
.pw-listitem:hover { border-color: var(--color-muted); }
.pw-listitem.is-selected { border-color: var(--color-accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-accent) 16%, transparent); }
.pw-li-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.pw-li-vendor { font-weight: var(--fw-medium); }
.pw-li-sub { font-size: var(--fs-xs); color: var(--color-label); }
.pw-li-meta { font-size: var(--fs-xs); color: var(--color-muted); margin-top: 2px; }
.pw-actions { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.pw-actions .btn { width: 100%; }
.pw-po { background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--radius-card); padding: var(--space-5); max-width: 680px; margin: 0 auto; }
.pw-po-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); }
.pw-po-title { font-size: var(--fs-lg); font-weight: var(--fw-semibold); display: flex; align-items: center; gap: var(--space-2); }
.pw-po-vendor { font-weight: var(--fw-medium); margin-top: var(--space-2); }
.pw-po-sub { font-size: var(--fs-sm); color: var(--color-label); }
.pw-po-shipto { min-width: 200px; text-align: right; }
.pw-po-shipto .field-label { display: block; margin-bottom: 2px; }
.pw-table { width: 100%; border-collapse: collapse; margin-top: var(--space-3); }
.pw-table th { text-align: left; font-size: var(--fs-xs); color: var(--color-label); font-weight: var(--fw-medium); padding: var(--space-1) var(--space-2); border-bottom: 1px solid var(--color-border); }
.pw-table td { padding: var(--space-2); border-bottom: 1px solid var(--color-border-faint); vertical-align: top; font-size: var(--fs-sm); }
.pw-sku { font-size: var(--fs-xs); color: var(--color-muted); }
.pw-qtycell { width: 90px; }
.pw-qty { width: 80px; height: 30px; padding: 0 var(--space-2); text-align: right; font-size: var(--fs-sm); }
.pw-qty:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent); }
.pw-rm { appearance: none; border: none; background: none; color: var(--color-muted); cursor: pointer; padding: 2px 6px; border-radius: var(--radius-input); }
.pw-rm:hover { background: var(--color-hover); color: var(--color-danger-text); }
.pw-po-foot { margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--color-label); text-align: right; }
.pw-empty { color: var(--color-muted); text-align: center; padding: var(--space-4); }
.q-rm { appearance: none; border: none; background: none; color: var(--color-muted); cursor: pointer; font-size: var(--fs-base); padding: var(--space-1); border-radius: var(--radius-input); }
.q-rm:hover { background: var(--color-hover); color: var(--color-danger-text); }

/* Order-queue checkbox in the grid item cell */
.q-check { margin-right: var(--space-2); vertical-align: middle; }
.sp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--color-border-faint);
  font-size: var(--fs-sm);
}
.sp-doc { color: var(--color-text); font-weight: var(--fw-medium); }
.sp-meta { color: var(--color-label); margin-top: 2px; }
.sp-row .qty { font-variant-numeric: tabular-nums; white-space: nowrap; }
.sp-row .qty.neg { color: var(--color-danger-text); }
.sp-total { border-bottom: none; }
.sp-total .sp-doc, .sp-total .qty { font-weight: var(--fw-semibold); }
.sp-empty { padding: var(--space-4) 0; color: var(--color-muted); font-size: var(--fs-sm); }
.sp-foot {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border);
}
.sp-foot a { color: var(--color-accent); font-size: var(--fs-sm); text-decoration: none; }
.sp-foot a:hover { text-decoration: underline; }

/* ---- Modal --------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 15vh;
}
.modal {
  width: 360px;
  background: var(--color-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-md);
  padding: var(--space-5);
}
/* Wide modal: the item selector table */
.modal--wide {
  --pk-pad: var(--space-6);
  width: 1280px;
  max-width: 96vw;
  display: flex;
  flex-direction: column;
  height: 86vh;
  padding: var(--space-5) var(--pk-pad) var(--space-4);
}
.modal-backdrop:has(.modal--wide) { padding-top: 7vh; }
.pk-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.pk-modal-head h2 { margin: 0; font-size: var(--fs-lg); font-weight: var(--fw-semibold); white-space: nowrap; }
.pk-modal-head .sp-close { position: static; }
/* Full-width shadcn search (icon + clear) at the top of the picker. */
.pk-search-wrap { display: flex; width: 100%; margin-bottom: var(--space-3); flex: none; }
.pk-search-wrap .search { width: 100%; height: 36px; font-size: var(--fs-base); }
.modal-actions--spaced { margin-top: var(--space-4); align-items: center; }

/* Select-all-by-role bar in the item picker. */
.pk-typebar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.pk-typebar-label { font-size: var(--fs-sm); color: var(--color-label); }

/* Buy / make / sell role chips (picker column + item drill pane). */
.type-chip {
  display: inline-block;
  padding: 1px var(--space-2);
  margin-right: var(--space-1);
  border-radius: var(--radius-pill, 999px);
  font-size: var(--fs-xs, 11px);
  font-weight: var(--fw-medium);
  text-transform: capitalize;
  background: var(--pill-gray-bg);
  color: var(--pill-gray-text);
}
.type-chip--make { background: var(--pill-green-bg); color: var(--pill-green-text); }
.type-chip--buy  { background: var(--pill-blue-bg);  color: var(--pill-blue-text); }
.type-chip--sell { background: var(--pill-violet-bg); color: var(--pill-violet-text); }
.pk-typecell { white-space: nowrap; }
/* Full-bleed table: runs to the modal's edges (no boxed border); the first
   and last cells pad back to the modal's inset (golden rule 6). */
.pk-tablewrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  margin: 0 calc(-1 * var(--pk-pad));
  border-bottom: 1px solid var(--color-border-faint);
}
.pk-table { width: 100%; }
.pk-table th:first-child, .pk-table td:first-child { padding-left: var(--pk-pad); }
.pk-table th:last-child, .pk-table td:last-child { padding-right: var(--pk-pad); }
.pk-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--color-bg);
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

/* Header cell: drag grip + label + sort icon (click = sort), and a filter /
   options button. Drag the header to reorder columns. */
.pk-th { user-select: none; cursor: grab; }
.pk-table th.pk-th { padding: 0 var(--space-2); }
.pk-table th.pk-th:last-child { padding-right: calc(var(--pk-pad) - var(--space-1)); }
/* Label sits at the cell-text inset (th 8px + button 4px = the td 12px); the
   hover-revealed grip + filter button trail it (lead it on numeric columns,
   so the label stays right-aligned with the numbers). */
.pk-th-inner { display: flex; align-items: center; gap: 2px; }
.pk-th-sort { flex: 0 1 auto; }
.pk-th-tools { display: inline-flex; align-items: center; margin-left: auto; }
.pk-th.num .pk-th-inner { flex-direction: row-reverse; }
.pk-th.num .pk-th-tools { margin-left: 0; margin-right: auto; flex-direction: row-reverse; }
.pk-th-sort {
  appearance: none; border: none; background: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: var(--space-1);
  height: 28px; padding: 0 var(--space-1); border-radius: var(--radius-input);
  font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); color: var(--color-label);
  white-space: nowrap;
}
.pk-th-sort:hover { background: var(--color-hover); color: var(--color-text); }
.pk-th.is-sorted .pk-th-sort { color: var(--color-text); }
.pk-grip { width: 12px; height: 12px; color: var(--color-muted); opacity: 0; transition: opacity 0.1s ease; }
.pk-th:hover .pk-grip { opacity: 1; }
.pk-sorticon { width: 13px; height: 13px; }
.pk-sorticon--idle { color: var(--color-muted); opacity: 0; }
.pk-th:hover .pk-sorticon--idle { opacity: 1; }
.pk-th-menu {
  appearance: none; border: none; background: none; cursor: pointer;
  width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-input); color: var(--color-muted); opacity: 0;
}
.pk-th-menu .icon { width: 13px; height: 13px; }
.pk-th:hover .pk-th-menu, .pk-th.is-open .pk-th-menu, .pk-th.is-filtered .pk-th-menu { opacity: 1; }
.pk-th-menu:hover, .pk-th.is-open .pk-th-menu { background: var(--color-hover); color: var(--color-text); }
.pk-th.is-filtered .pk-th-menu { color: var(--color-accent); }
.pk-th.is-filtered .pk-th-menu .icon { fill: currentColor; }
.pk-th.is-dragging { opacity: 0.45; }
.pk-th.drop-before { box-shadow: inset 2px 0 0 var(--color-accent); }
.pk-th.drop-after { box-shadow: inset -2px 0 0 var(--color-accent); }

/* Column menu: the dropdown popover panel (fixed so the table can't clip it). */
.pk-colmenu {
  position: fixed; z-index: 70; width: 248px;
  background: var(--color-bg);
  border: 1px solid var(--color-border-faint);
  border-radius: var(--radius-input);
  box-shadow: var(--shadow-md);
  padding: var(--space-1);
}
.pk-mi {
  appearance: none; border: none; background: none; cursor: pointer; width: 100%;
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2); border-radius: var(--radius-input);
  font: inherit; font-size: var(--fs-base); color: var(--color-text); text-align: left;
}
.pk-mi .icon { width: 14px; height: 14px; color: var(--color-label); }
.pk-mi:hover:not(:disabled) { background: var(--color-hover); }
.pk-mi.is-on { font-weight: var(--fw-medium); }
.pk-mi.is-on .icon { color: var(--color-accent); }
.pk-mi:disabled { color: var(--color-muted); cursor: default; }
.pk-mi:disabled .icon { color: var(--color-muted); }
.pk-sep { height: 1px; background: var(--color-border-faint); margin: var(--space-1) calc(-1 * var(--space-1)); }
.pk-mlabel { font-size: var(--fs-xs); color: var(--color-muted); padding: var(--space-1) var(--space-2); }
.pk-colmenu .input { width: 100%; }
.pk-f-text { margin: 0 0 var(--space-1); }
.pk-colmenu .pk-f-text, .pk-f-range { padding: 0 var(--space-1); }
.pk-f-range { display: flex; gap: var(--space-2); margin-bottom: var(--space-1); }
.pk-f-list { max-height: 220px; overflow-y: auto; }
.pk-f-opt {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 6px var(--space-2); border-radius: var(--radius-input);
  font-size: var(--fs-base); cursor: pointer;
}
.pk-f-opt:hover { background: var(--color-hover); }
.pk-f-val { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk-f-count { font-size: var(--fs-xs); color: var(--color-muted); font-variant-numeric: tabular-nums; }
.pk-fclear { display: block; margin-top: var(--space-1); }

.pk-countbar { display: flex; align-items: center; gap: var(--space-3); flex: none; }
.pk-countbar .pk-count { flex: 1; }
.pk-table th, .pk-table td { text-align: left; }
.pk-table td.num, .pk-table th.num { text-align: right; }
.pk-table .pk-cb { width: calc(var(--pk-pad) + 28px); text-align: left; }
.pk-table td.pk-cb input, .pk-table th.pk-cb input { display: grid; }
.pk-table .pk-partno { font-weight: var(--fw-medium); white-space: nowrap; }
.pk-table .pk-desccell { color: var(--color-label); max-width: 320px; overflow: hidden; text-overflow: ellipsis; }
.pk-tr { cursor: pointer; }
.pk-tr:hover { background: var(--color-hover); }
.pk-tr.on { background: var(--color-surface-alt); }
.pk-empty { text-align: center; color: var(--color-muted); padding: var(--space-6) 0; }
.pk-count { font-size: var(--fs-sm); color: var(--color-muted); padding: var(--space-1) 0 var(--space-2); }
.pk-selected { flex: 1; font-size: var(--fs-sm); color: var(--color-label); }
.modal h2 {
  margin: 0 0 var(--space-3);
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
}
.modal .modal-body { margin-bottom: var(--space-4); font-size: var(--fs-base); }
.modal .modal-body .field-label { display: block; margin-bottom: var(--space-1); }
.modal .modal-body .input { width: 100%; }
.modal .modal-hint { font-size: var(--fs-sm); color: var(--color-label); margin-top: var(--space-2); }
.modal .modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
}
