/* ============================================================
   Purchase Orders v2 — show + edit pages.
   Show page is the canonical visual source (iterated past the
   original spec/po_ui_v2/POViewPrototype.html). Edit page mirrors
   show's DOM and patterns. Both wrap content in:
     <div class="po-v2 po-show"> ... </div>
     <div class="po-v2 po-edit"> ... </div>

   IMPORTANT: stylesheet_link_tag :app bundles every CSS file in
   app/assets/stylesheets/ on every page, so every selector here
   MUST be scoped under .po-v2 to prevent collisions with
   replenishment_v2.css (.sku-cell), application.css (.po-tab-panel,
   .pagination-*, etc.), or any future stylesheet.

   Modals (.po-modal*) are rendered inside .po-v2 — their
   position:fixed handles overlay z-index regardless of nesting.
   ============================================================ */

.po-v2 {
  /* ---------- BASE TOKENS ----------
     --bg, --ink, --border, --accent, --green, --amber, --red, --purple,
     --muted, --light, --surface, --surface-alt, --border-light, --border-hover
     come from application.css. PO show adds the rest. */
  --row-divider:   #f5f4f2;

  --bg-healthy:    #dcfce7;  --fg-healthy:    #16a34a;
  --bg-low:        #fffbeb;  --fg-low:        #d97706;
  --bg-oos:        #fef2f2;  --fg-oos:        #dc2626;
  --bg-over:       #f5f3ff;  --fg-over:       #7c3aed;
  --bg-info:       #eff6ff;  --fg-info:       #3b82f6;

  --shadow-menu:   0 8px 30px rgba(0, 0, 0, 0.12);
  --shadow-focus:  0 0 0 2px rgba(26, 26, 26, 0.08);

  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 10px;
  --r-2xl: 12px;
  --r-full: 999px;

  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Menlo', monospace;
}

/* ---------- BREADCRUMB ---------- */
.po-v2 .crumb { font-size: 12px; color: var(--muted); margin-bottom: 10px; padding: 0 4px; }
.po-v2 .crumb a { color: var(--muted); text-decoration: none; }
.po-v2 .crumb a:hover { color: var(--ink); }

/* ---------- UNIFIED PO SURFACE ---------- */
.po-v2 .po-surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  overflow: hidden;
  font-family: var(--font-sans);
  color: var(--ink);
}
.po-v2 .po-sec { padding: 18px 24px; border-top: 1px solid var(--border-light); }
.po-v2 .po-sec:first-child { border-top: none; }
.po-v2 .po-sec.tight { padding: 14px 24px; }
.po-v2 .po-sec.flush { padding: 0; }

/* Defeat the legacy .po-tab-panel rule from application.css (display:none + padding-top:16px).
   Our show page switches panels via inline style="display:..." but specificity matters
   because .po-tab-panel.active sets display:block; we want neither rule to apply. */
.po-v2 .po-tab-panel { padding-top: 0; }

/* ---------- BUTTONS ---------- */
.po-v2 .btn {
  font-family: inherit; font-size: 12px; font-weight: 600; padding: 8px 14px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer; display: inline-flex;
  align-items: center; gap: 6px; transition: all .15s; line-height: 1; white-space: nowrap;
}
.po-v2 .btn svg { width: 14px; height: 14px; stroke-width: 2; }
.po-v2 .btn-accent { background: var(--accent); color: #fff; padding: 9px 18px; font-size: 13px; }
.po-v2 .btn-accent:hover { opacity: 0.9; }
.po-v2 .btn-secondary { background: #fff; border-color: var(--border-hover); color: var(--ink); }
.po-v2 .btn-secondary:hover { border-color: var(--ink); }
.po-v2 .btn-ghost { background: transparent; border-color: transparent; color: var(--muted); padding: 7px 10px; font-weight: 500; }
.po-v2 .btn-ghost:hover { background: var(--surface-alt); color: var(--ink); }
.po-v2 .btn-sm { padding: 6px 10px; font-size: 11px; border-radius: 6px; }

/* button_to wraps in <form> by default, which renders block. Inside the
   action cluster we want those forms to flow inline next to <button> and
   <a> siblings. Scope tight — broader form rules break the reject modal
   form, the bulk-ETA popover form, etc. */
.po-v2 .po-h-actions form { display: inline-flex; }

/* ---------- KEBAB ---------- */
.po-v2 .kebab { position: relative; }
.po-v2 .kebab > .btn { padding: 8px 10px; }
.po-v2 .kebab-menu {
  position: absolute; right: 0; top: calc(100% + 4px); background: #fff;
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  min-width: 180px; z-index: 30; padding: 4px;
}
.po-v2 .kebab-menu[hidden] { display: none; }
.po-v2 .kebab-menu .item {
  display: flex; align-items: center; gap: 8px; padding: 7px 10px;
  font-size: 12px; color: var(--ink); border-radius: 5px; cursor: pointer;
  background: none; border: none; width: 100%; text-align: left; font-family: inherit;
  font-weight: 500; text-decoration: none;
}
.po-v2 .kebab-menu .item:hover { background: var(--surface-alt); }
.po-v2 .kebab-menu .item svg { width: 14px; height: 14px; color: var(--muted); }
.po-v2 .kebab-menu .item.danger { color: var(--red); }
.po-v2 .kebab-menu .item.danger svg { color: var(--red); }
.po-v2 .kebab-menu .item.danger:hover { background: var(--bg-oos); }
.po-v2 .kebab-menu hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.po-v2 .kebab-menu form { display: block; }
.po-v2 .kebab-menu form .item { width: 100%; }

/* ---------- PO HEADER ---------- */
.po-v2 .po-h { padding: 22px 24px 18px; }
.po-v2 .po-h-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.po-v2 .po-h-id { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.po-v2 .po-h-num { font-size: 26px; font-weight: 700; letter-spacing: -0.4px; font-family: var(--font-mono); }
.po-v2 .po-h-vendor { font-size: 15px; color: var(--muted); font-weight: 500; }
.po-v2 .po-h-vendor b { color: var(--ink); font-weight: 600; }
.po-v2 .po-h-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }

.po-v2 .po-h-meta {
  display: grid; grid-template-columns: repeat(4, max-content); gap: 24px 36px;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border-light);
}
.po-v2 .po-h-meta .lbl {
  display: block; font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 4px;
}
.po-v2 .po-h-meta .val { font-size: 14px; font-weight: 600; color: var(--ink); }
.po-v2 .po-h-meta .val.mono { font-family: var(--font-mono); }
.po-v2 .po-h-meta .val .sub { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 4px; }
.po-v2 .po-h-meta .val .awaiting { color: var(--muted); font-weight: 500; }

/* Assignee meta cell — value plus a small "edit" affordance to open reassign modal. */
.po-v2 .po-assignee { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.po-v2 .po-assignee__edit {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border-radius: 4px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer; transition: all 0.12s;
}
.po-v2 .po-assignee__edit svg { width: 11px; height: 11px; }
.po-v2 .po-assignee__edit:hover { background: var(--surface-alt); color: var(--ink); border-color: var(--border); }

/* Modal select — same shape as the textarea/input form controls. */
.po-modal__select {
  width: 100%; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  color: var(--ink); font-family: inherit;
}
.po-modal__select:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 2px rgba(26,26,26,0.08);
}

.po-v2 .po-h-notes { display: flex; flex-direction: column; gap: 6px; margin-top: 14px; }
.po-v2 .po-h-note {
  background: transparent; border: none; border-left: 2px solid var(--border);
  border-radius: 0; padding: 4px 12px; font-size: 12px; color: var(--ink);
  display: flex; gap: 10px; align-items: baseline; line-height: 1.5;
}
.po-v2 .po-h-note .nlbl { font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted); flex-shrink: 0; }

/* ---------- BANNER (missing-ETA, etc.) ---------- */
.po-v2 .banner-warn {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-low); border-top: 1px solid #fde68a; border-bottom: 1px solid #fde68a;
  padding: 12px 24px; font-size: 13px; line-height: 1.5; color: #78350f;
}
.po-v2 .banner-warn svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--amber); }
.po-v2 .banner-warn b { color: var(--ink); }
.po-v2 .banner-warn a { color: var(--amber); font-weight: 600; text-decoration: underline; margin-left: 4px; }
.po-v2 .eta-missing { display: inline-flex; align-items: center; gap: 4px; color: var(--amber); font-style: italic; font-size: 12px; cursor: help; }
.po-v2 .eta-missing svg { width: 13px; height: 13px; }

/* ---------- COMPRESSED PILL TIMELINE ---------- */
.po-v2 .ptl-wrap { padding: 12px 24px; border-top: 1px solid var(--border-light); }
.po-v2 .ptl {
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 10px 6px 14px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; cursor: pointer; user-select: none; transition: border-color 0.15s;
}
.po-v2 .ptl:hover { border-color: var(--border-hover); background: #fff; }
.po-v2 .ptl-track { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; overflow: hidden; }
.po-v2 .ptl-step {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap;
}
.po-v2 .ptl-step.done { color: var(--green); }
.po-v2 .ptl-step.done::before {
  content: '✓'; font-size: 10px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--bg-healthy); color: var(--green); display: inline-flex;
  align-items: center; justify-content: center; font-weight: 700;
}
.po-v2 .ptl-step.active {
  background: var(--bg-low); color: var(--amber); padding: 4px 12px;
  box-shadow: 0 0 0 1px #fde68a;
}
.po-v2 .ptl-step.active::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--amber);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.18);
}
.po-v2 .ptl-step.future { color: var(--light); }
.po-v2 .ptl-step.future::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  border: 1.5px solid var(--border-hover);
}
.po-v2 .ptl-arrow { color: var(--light); font-size: 10px; }
.po-v2 .ptl-toggle {
  font-size: 11px; color: var(--muted); display: flex; align-items: center;
  gap: 4px; padding-left: 10px; border-left: 1px solid var(--border); flex-shrink: 0;
}
.po-v2 .ptl-toggle svg { width: 12px; height: 12px; transition: transform 0.15s; }
.po-v2 .ptl.open .ptl-toggle svg { transform: rotate(180deg); }

/* ---------- TABS ---------- */
.po-v2 .tabs {
  display: flex; gap: 0; border-top: 1px solid var(--border-light);
  border-bottom: 1px solid var(--border); padding: 0 24px;
  background: linear-gradient(to bottom, #fafaf7 0%, #fff 100%);
}
.po-v2 .tab {
  font: inherit; font-size: 14px; font-weight: 500; color: var(--muted);
  background: none; border: none; padding: 12px 18px; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 8px; transition: color 0.15s;
}
.po-v2 .tab:hover { color: var(--ink); }
.po-v2 .tab.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.po-v2 .tab .ct {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  background: var(--surface-alt); padding: 1px 7px; border-radius: 999px;
  font-weight: 600;
}
.po-v2 .tab.on .ct { color: var(--accent); background: #fef2ee; }

.po-v2 .dc-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted); cursor: pointer;
  padding: 5px 10px; border-radius: 6px;
}
.po-v2 .dc-toggle:hover { background: var(--surface-alt); color: var(--ink); }
.po-v2 .dc-toggle input { accent-color: var(--ink); margin: 0; }

/* ---------- LINE ITEMS WORKSPACE ---------- */
.po-v2 .li-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; padding: 16px 24px 12px;
}
.po-v2 .li-head h2 { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.po-v2 .li-head-mid {
  display: flex; gap: 6px; align-items: center; flex-wrap: wrap;
  flex: 1; justify-content: flex-start; margin-left: 12px;
}

.po-v2 .pchip {
  display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px;
  border-radius: 999px; font-size: 11px; font-weight: 600; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  transition: all 0.12s;
}
.po-v2 .pchip:hover { border-color: var(--border-hover); }
.po-v2 .pchip.warn { background: var(--bg-low); border-color: #fde68a; color: var(--amber); }
.po-v2 .pchip.warn:hover { background: #fef3c7; border-color: #fcd34d; }
.po-v2 .pchip.crit { background: var(--bg-oos); border-color: #fecaca; color: var(--red); }
.po-v2 .pchip.crit:hover { background: #fee2e2; border-color: #fca5a5; }
.po-v2 .pchip.info { color: var(--ink); }
.po-v2 .pchip svg { width: 11px; height: 11px; }
.po-v2 .pchip .ct { font-family: var(--font-mono); font-weight: 700; }

.po-v2 .seg {
  display: inline-flex; background: var(--surface-alt); padding: 3px;
  border-radius: 8px; gap: 2px; border: 1px solid var(--border);
}
.po-v2 .seg button,
.po-v2 .seg a {
  font: inherit; font-size: 11px; font-weight: 600; padding: 5px 12px;
  border-radius: 5px; border: none; background: transparent; color: var(--muted);
  cursor: pointer; text-decoration: none; transition: color 0.12s;
}
.po-v2 .seg a:hover { color: var(--ink); }
.po-v2 .seg button.on,
.po-v2 .seg a.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.05); }

/* Toolbar (search + actions) */
.po-v2 .li-tools {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 0 24px 14px;
}
.po-v2 .search { position: relative; max-width: 320px; flex: 1; min-width: 200px; }
.po-v2 .search input {
  width: 100%; font: inherit; font-size: 13px; padding: 8px 32px 8px 32px;
  border: 1px solid var(--border); border-radius: 8px; background: #fff;
}
.po-v2 .search input:focus { outline: none; border-color: var(--ink); box-shadow: var(--shadow-focus); }
.po-v2 .search .ico {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--muted); pointer-events: none;
}
.po-v2 .btn-ai {
  background: linear-gradient(135deg, #fff 0%, #fef2ee 100%); color: var(--accent);
  border: 1px solid var(--accent);
}
.po-v2 .btn-ai:hover { background: #fef2ee; }
.po-v2 .btn-ai svg { width: 14px; height: 14px; }
.po-v2 .ctx-chip {
  font-size: 10px; color: var(--light); text-decoration: none;
  padding: 4px 8px; border-radius: 4px; opacity: 0.5; font-family: var(--font-mono);
  margin-left: auto;
}
.po-v2 .ctx-chip:hover { opacity: 1; background: var(--bg); }
.po-v2 .help-icon {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border);
  background: #fff; color: var(--muted); display: inline-flex; align-items: center;
  justify-content: center; font-size: 11px; font-weight: 700; cursor: help;
  font-family: var(--font-mono);
}

/* Update ETAs popover (used on both show + edit toolbars) */
.po-v2 .upd-eta-host { position: relative; }
.po-v2 .upd-eta-pop {
  position: absolute; top: calc(100% + 6px); left: 0;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0,0,0,0.12); padding: 16px 18px;
  display: none; z-index: 30; min-width: 380px;
}
.po-v2 .upd-eta-pop.open { display: block; }
.po-v2 .upd-eta-pop h4 { margin: 0 0 4px; font-size: 14px; font-weight: 700; color: var(--ink); }
.po-v2 .upd-eta-pop p { margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.po-v2 .upd-eta-row {
  display: flex; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 13px;
}
.po-v2 .upd-eta-row label {
  font-size: 10px; color: var(--muted); font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; min-width: 76px;
  margin: 0;
}
.po-v2 .upd-eta-row input[type="date"], .po-v2 .upd-eta-row select {
  font: inherit; font-family: var(--font-sans); font-size: 13px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--ink); flex: 1;
}
.po-v2 .upd-eta-row input[type="date"]:focus,
.po-v2 .upd-eta-row select:focus {
  outline: none; border-color: var(--ink); box-shadow: var(--shadow-focus);
}
.po-v2 .upd-eta-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-light);
}

/* Highlight per-line ETA inputs that are still empty so the buyer can spot
   which lines a "Lines without ETA" bulk apply will hit. The class is added
   server-side and removed by po-eta-bulk#applyEta when the row gets a date. */
.po-v2 .li-cell-input.is-eta-missing {
  background: var(--bg-low); border-color: #fde68a;
}
.po-v2 .li-cell-input.is-eta-missing:focus {
  border-color: var(--ink); box-shadow: var(--shadow-focus); background: #fff;
}

/* ---------- TABLE ---------- */
.po-v2 .li-card { border-top: 1px solid var(--border); background: #fff; }
.po-v2 table.li { width: 100%; border-collapse: collapse; font-size: 13px; }
.po-v2 table.li thead th {
  background: #fafaf7; color: var(--muted); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap;
}
.po-v2 table.li thead th:first-child { padding-left: 24px; }
.po-v2 table.li thead th:last-child { padding-right: 24px; }
.po-v2 table.li tbody td:first-child { padding-left: 24px; }
.po-v2 table.li tbody td:last-child { padding-right: 24px; }
.po-v2 table.li tfoot td:first-child { padding-left: 24px; }
.po-v2 table.li tfoot td:last-child { padding-right: 24px; }
.po-v2 table.li thead th.num { text-align: right; }
.po-v2 table.li tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--row-divider);
  vertical-align: middle; font-size: 13px; text-align: left;
}
.po-v2 table.li tbody td.num {
  text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}
.po-v2 table.li tbody tr:hover { background: var(--surface-alt); }
.po-v2 table.li tbody tr:last-child td { border-bottom: none; }
.po-v2 table.li tfoot td {
  background: var(--surface-alt); padding: 11px 14px;
  border-top: 2px solid var(--border); border-bottom: none;
  font-size: 12px; font-weight: 700; color: var(--ink); vertical-align: middle;
}
.po-v2 table.li tfoot td.num {
  text-align: right; font-variant-numeric: tabular-nums; font-family: var(--font-mono);
}
.po-v2 table.li tfoot td .ft-label {
  font-family: var(--font-sans); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; color: var(--muted);
}
.po-v2 table.li tfoot td .ft-meta {
  display: block; font-family: var(--font-sans); font-size: 11px;
  font-weight: 500; color: var(--muted); margin-top: 2px;
}

/* In-header search: SKU/Item label on the left, real search input on the right. */
.po-v2 table.li thead th.li-search-th {
  padding: 6px 14px 6px 24px; display: flex; align-items: center; gap: 12px;
}
.po-v2 .li-search-label {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; white-space: nowrap;
  flex-shrink: 0;
}
.po-v2 .li-search {
  position: relative; display: flex; align-items: center;
  flex: 1; max-width: 240px;
}
.po-v2 .li-search .ico {
  position: absolute; left: 9px; top: 50%; transform: translateY(-50%);
  color: var(--muted); pointer-events: none;
}
.po-v2 .li-search input {
  flex: 1; font: inherit; font-family: var(--font-sans); font-size: 12px;
  font-weight: 500; padding: 6px 10px 6px 28px; min-width: 0;
  border: 1px solid var(--border); background: #fff; border-radius: 6px;
  color: var(--ink); transition: border-color 0.15s, box-shadow 0.15s;
}
.po-v2 .li-search input::placeholder {
  color: var(--muted); font-weight: 400; font-size: 12px;
  text-transform: none; letter-spacing: 0;
}
.po-v2 .li-search input:hover { border-color: var(--border-hover); }
.po-v2 .li-search input:focus {
  border-color: var(--ink); outline: none; box-shadow: var(--shadow-focus);
}

/* SKU cell — these names collide with replenishment_v2.css; the .po-v2 prefix
   bumps specificity over the generic .sku-cell rule on /replenishment pages.
   Cell is no longer wrapped in <a>; SKU code has a copy affordance and the
   product name has an open-in-new-tab button next to it (.sku-open). */
.po-v2 .sku-cell { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; min-width: 220px; }
.po-v2 .sku-code-row { display: inline-flex; align-items: center; gap: 4px; }
.po-v2 .sku-code {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  user-select: text; -webkit-user-select: text;
}
.po-v2 .sku-name {
  font-weight: 450; font-size: 13px; color: var(--ink);
  user-select: text; -webkit-user-select: text;
}
/* Both action buttons (copy + open) always visible; sit inline with the SKU code. */
.po-v2 .sku-open {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  color: var(--light); text-decoration: none; flex-shrink: 0;
  transition: background 0.12s, color 0.12s;
}
.po-v2 .sku-open svg { width: 11px; height: 11px; }
.po-v2 .sku-open:hover { background: var(--surface-alt); color: var(--blue); }
.po-v2 .sku-open:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.po-v2 .sku-copy {
  display: inline-flex; align-items: center; justify-content: center;
  height: 18px; min-width: 18px; padding: 0; border-radius: 4px;
  color: var(--light); cursor: pointer;
  transition: background 0.12s, color 0.12s, padding 0.12s;
}
.po-v2 .sku-copy svg { width: 11px; height: 11px; }
.po-v2 .sku-copy:hover { background: var(--surface-alt); color: var(--ink); }
.po-v2 .sku-copy:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
/* When showing the "Copied" flash, expand the button so the text doesn't
   spill onto the adjacent SKU code. Soft green tint reinforces success. */
.po-v2 .sku-copy.is-copied { padding: 0 6px; background: var(--bg-healthy); }
.po-v2 .copy-flash {
  font-size: 10px; font-weight: 700; color: var(--green);
  white-space: nowrap; line-height: 1;
}
.po-v2 .qty-num { font-variant-numeric: tabular-nums; font-weight: 600; }
.po-v2 .dc-split {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  background: var(--surface-alt); padding: 2px 7px; border-radius: 4px;
  margin-left: 8px; white-space: nowrap; letter-spacing: 0.4px;
}
/* Default: per-DC split hidden — toggle reveals (po_show_design_final_decisions §2.8) */
.po-v2 .po-line-items[data-show-per-location="false"] .dc-split,
.po-v2 .po-line-items:not([data-show-per-location]) .dc-split { display: none; }

.po-v2 .ico-info, .po-v2 .ico-warn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 14px; height: 14px; border-radius: 50%; cursor: help; margin-left: 5px;
  vertical-align: middle;
}
.po-v2 .ico-info svg, .po-v2 .ico-warn svg { width: 11px; height: 11px; stroke-width: 2; }
.po-v2 .ico-info { color: var(--muted); }
.po-v2 .ico-warn { color: var(--amber); }

/* CSS-only tooltip used by the prototype. */
.po-v2 .tt-host { position: relative; display: inline-flex; align-items: center; }
.po-v2 .tt-bubble {
  visibility: hidden; opacity: 0; position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); background: var(--ink); color: #fff;
  font-size: 12px; line-height: 1.4; padding: 8px 12px; border-radius: 8px;
  max-width: 280px; min-width: 200px; white-space: normal; z-index: 50;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15); transition: opacity 0.2s;
  pointer-events: none; text-align: left; font-weight: 400;
}
.po-v2 .tt-bubble::after {
  content: ''; position: absolute; top: 100%; left: 50%;
  transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink);
}
.po-v2 .tt-host:hover .tt-bubble,
.po-v2 .tt-host:focus-within .tt-bubble { visibility: visible; opacity: 1; }

/* ---------- COVERAGE chip ---------- */
.po-v2 .cov {
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 5px; display: inline-block;
}
.po-v2 .cov-crit { color: #991b1b; background: #fee2e2; border: 1px solid #fca5a5; }
.po-v2 .cov-warn { color: #92400e; background: #fef3c7; border: 1px solid #fcd34d; }
.po-v2 .cov-ok   { color: var(--green); background: var(--bg-healthy); border: 1px solid #86efac; }
.po-v2 .cov-over { color: var(--purple); background: var(--bg-over); border: 1px solid #ddd6fe; }
.po-v2 .cov-none { color: var(--muted); }

/* ---------- INLINE RECEIVE WIDGET ---------- */
.po-v2 .po-receive-inline {
  display: inline-flex; align-items: center; padding: 2px 6px;
  border-radius: 4px; border: 1px dashed transparent;
  transition: border-color 0.15s, background 0.15s;
}
.po-v2 .po-receive-inline:hover { border-color: var(--border-hover); background: var(--surface-alt); }
.po-v2 .po-receive-inline:focus-within { border-style: solid; border-color: var(--ink); }
.po-v2 .po-receive-inline-edit {
  display: inline-flex; align-items: center; gap: 4px;
}
.po-v2 .po-receive-inline-input {
  font: inherit; font-family: var(--font-mono); font-size: 12px;
  width: 64px; padding: 3px 6px; text-align: right;
  border: 1px solid var(--ink); border-radius: 4px; background: #fff;
  font-variant-numeric: tabular-nums;
}
.po-v2 .po-receive-inline-input:focus { outline: none; box-shadow: var(--shadow-focus); }
.po-v2 .po-receive-inline-submit {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border-radius: 4px;
  background: var(--green); color: #fff; border: none;
  cursor: pointer; transition: opacity 0.12s;
}
.po-v2 .po-receive-inline-submit:hover { opacity: 0.9; }

/* Subtle dimming on Qty Avail = 0 so buyers spot starved DCs at a glance. */
.po-v2 .qty-num.is-zero { color: var(--muted); }

/* Received column — green when positive (progress visible). */
.po-v2 .qty-num.received { color: var(--green); font-weight: 600; }

/* Outstanding column — red when something's still expected, struck-through
   in muted color when the line is closed (qty written off, not coming). */
.po-v2 .qty-num.outstanding { color: var(--red); font-weight: 600; }
.po-v2 .qty-num.outstanding-closed {
  color: var(--muted); text-decoration: line-through; font-weight: 500;
}

/* Closed-line row state — every cell muted + struck through. The row stays
   in the table so it's visible in receipt history, just visually parked. */
.po-v2 tr.is-closed td { background: var(--surface-alt); }
.po-v2 tr.is-closed .sku-name,
.po-v2 tr.is-closed .sku-code { text-decoration: line-through; color: var(--muted); }
.po-v2 tr.is-closed .qty-num { color: var(--muted); }

/* Close / Reopen buttons — icon-only, tooltip on hover. */
.po-v2 .btn-row-close,
.po-v2 .btn-row-reopen {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 5px;
  background: transparent; border: 1px solid transparent;
  cursor: pointer; transition: all 0.12s;
}
.po-v2 .btn-row-close svg,
.po-v2 .btn-row-reopen svg { width: 13px; height: 13px; }
.po-v2 .btn-row-close { color: var(--muted); }
.po-v2 .btn-row-close:hover { background: var(--bg-oos); color: var(--red); border-color: #fecaca; }
.po-v2 .btn-row-reopen { color: var(--blue); }
.po-v2 .btn-row-reopen:hover { background: #eff6ff; border-color: #bfdbfe; }

/* Receive cell wraps the inline widget (or "X / Y" badge) and an undo button
   side-by-side so a fat-fingered receipt can be reversed in one click. */
.po-v2 .po-receive-cell {
  display: inline-flex; align-items: center; gap: 6px;
}
.po-v2 .btn-row-undo-receipt {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; padding: 0; border-radius: 5px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer; transition: all 0.12s;
}
.po-v2 .btn-row-undo-receipt:hover {
  background: var(--bg-oos); color: var(--red); border-color: #fecaca;
}
.po-v2 .btn-row-undo-receipt svg { width: 12px; height: 12px; }
/* button_to wraps in a <form> — strip default form spacing. */
.po-v2 form.button_to { display: inline; margin: 0; }

/* ---------- INLINE ETA EDITOR ---------- */
.po-v2 .po-eta-inline {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  border: 1px dashed transparent; transition: border-color 0.15s, background 0.15s;
}
.po-v2 .po-eta-inline:hover { border-color: var(--border-hover); background: var(--surface-alt); }
.po-v2 .po-eta-inline:focus-within { border-style: solid; border-color: var(--ink); }
.po-v2 .po-eta-inline-input {
  font: inherit; font-size: 12px; padding: 2px 6px;
  border: 1px solid var(--ink); border-radius: 4px; background: #fff;
  font-family: var(--font-mono);
}
.po-v2 .po-eta-inline-input:focus { outline: none; box-shadow: var(--shadow-focus); }

/* ---------- LATE chip ---------- */
.po-v2 .late {
  display: inline-flex; align-items: center; gap: 3px;
  background: var(--bg-oos); border: 1px solid #fecaca; color: var(--red);
  padding: 2px 6px; border-radius: 4px; font-family: var(--font-mono);
  font-size: 11px; font-weight: 700; margin-left: 6px; cursor: help;
}
.po-v2 .late svg { width: 11px; height: 11px; }

/* ---------- PROGRESS / RECEIVE not-yet-sent ---------- */
.po-v2 .prog-na {
  color: var(--muted); font-size: 12px;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.po-v2 .prog-pct { font-family: var(--font-mono); font-size: 12px; font-weight: 600; color: var(--ink); }
.po-v2 .prog-pct.done { color: var(--green); }

/* ---------- MOQ groups ----------
   Prototype: tinted bands per state. Below-MOQ uses warm cream (--bg-low),
   met uses soft green (--bg-healthy), unset stays transparent. The cross-PO
   annotation row inherits the same tint so the band reads as one block.
   SKU rows under a group keep the white table background so the tinted band
   visually frames the group; only the header + cross-po row carry the tint. */
.po-v2 tr.moq-row td {
  padding: 14px 14px 6px; border-bottom: none;
  border-top: 1px solid var(--border);
}
.po-v2 tr.moq-row.first td { border-top: none; }

.po-v2 tr.moq-row.below td,
.po-v2 tr.moq-cross.below td { background: var(--bg-low); }
.po-v2 tr.moq-row.met td,
.po-v2 tr.moq-cross.met td { background: var(--bg-healthy); }
.po-v2 tr.moq-row.unset td,
.po-v2 tr.moq-cross.unset td { background: transparent; }

.po-v2 tr.moq-cross td {
  padding: 0 14px 12px; border-bottom: 1px solid var(--border);
  font-size: 11px; color: var(--muted); line-height: 1.5;
}
.po-v2 tr.moq-cross b { color: var(--ink); font-weight: 600; }
.po-v2 tr.moq-cross code {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink);
  background: rgba(255,255,255,0.6); padding: 1px 5px; border-radius: 3px;
}

.po-v2 .moq-head-inner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.po-v2 .moq-name { font-size: 15px; font-weight: 700; color: var(--ink); text-decoration: none; }
.po-v2 a.moq-name:hover { color: var(--accent); text-decoration: underline; }
.po-v2 .moq-sep { color: var(--muted); }
.po-v2 .moq-agg { font-family: var(--font-mono); font-size: 13px; font-weight: 700; color: var(--ink); }
.po-v2 .moq-status {
  font-size: 11px; font-weight: 700; display: inline-flex; align-items: center;
  gap: 4px; padding: 3px 9px; border-radius: 999px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.po-v2 .moq-status svg { width: 12px; height: 12px; }
.po-v2 tr.moq-row.below .moq-status { color: var(--amber); background: #fef3c7; border: 1px solid #fde68a; }
.po-v2 tr.moq-row.met   .moq-status { color: var(--green); background: #dcfce7; border: 1px solid #86efac; }
.po-v2 tr.moq-row.unset .moq-status { color: var(--muted); background: var(--surface-alt); border: 1px solid var(--border); }
.po-v2 tr.sku-row.under-group td:first-child { padding-left: 30px; }
.po-v2 tr.fully-received td { background: #f0faf5; }

/* ---------- STATUS BADGE (in title row) ---------- */
.po-v2 .po-h-id .badge {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 4px 9px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 4px; white-space: nowrap;
}
.po-v2 .b-draft     { background: var(--bg);          color: var(--muted); border: 1px solid var(--border); }
.po-v2 .b-pending   { background: var(--bg-low);      color: var(--amber); }
.po-v2 .b-sent      { background: var(--bg-info);     color: var(--blue); }
.po-v2 .b-shipped   { background: #eef2ff;            color: #4f46e5; }
.po-v2 .b-partial   { background: #ffedd5;            color: #9a3412; }
.po-v2 .b-closed    { background: var(--bg-healthy);  color: var(--green); }
.po-v2 .b-cancelled { background: var(--bg-oos);      color: var(--red); }

/* ---------- PAGINATION ---------- */
.po-v2 .pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--border-light); background: #fafaf7;
}
.po-v2 .pg-meta { font-size: 12px; color: var(--muted); }
.po-v2 .pg-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- ACTIVITY LOG ---------- */
.po-v2 .actlog { display: flex; flex-direction: column; gap: 0; padding: 4px 4px; }
.po-v2 .actlog-entry {
  display: grid; grid-template-columns: 24px 1fr; gap: 12px;
  padding: 14px 0; border-bottom: 1px solid var(--row-divider); position: relative;
}
.po-v2 .actlog-entry:last-child { border-bottom: none; }
.po-v2 .actlog-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--ink);
  margin: 6px 0 0 6px; position: relative; z-index: 2;
}
.po-v2 .actlog-entry::before {
  content: ''; position: absolute; left: 16px; top: 22px;
  bottom: -6px; width: 1px; background: var(--border);
}
.po-v2 .actlog-entry:last-child::before { display: none; }
.po-v2 .actlog-dot.create { background: var(--green); }
.po-v2 .actlog-dot.edit { background: var(--blue); }
.po-v2 .actlog-dot.approve { background: var(--accent); }
.po-v2 .actlog-dot.receive { background: var(--purple); }
.po-v2 .actlog-dot.reject { background: var(--red); }
.po-v2 .actlog-head {
  display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; font-size: 13px;
}
.po-v2 .actlog-action { font-weight: 700; color: var(--ink); }
.po-v2 .actlog-actor { color: var(--ink); font-weight: 500; }
.po-v2 .actlog-time { color: var(--muted); font-size: 11px; }
.po-v2 .actlog-diff {
  margin-top: 6px; font-size: 11px; line-height: 1.7;
  background: var(--surface-alt); border-radius: 6px; padding: 8px 10px;
  font-family: var(--font-mono);
}
.po-v2 .actlog-diff .field { color: var(--muted); display: inline-block; min-width: 96px; }
.po-v2 .actlog-diff .from {
  color: var(--red); text-decoration: line-through;
  background: #fef2f2; padding: 0 3px; border-radius: 2px;
}
.po-v2 .actlog-diff .to {
  color: var(--green); background: #f0faf5; padding: 0 3px; border-radius: 2px;
}
.po-v2 .actlog-diff .arrow { color: var(--muted); margin: 0 5px; }
.po-v2 .actlog-meta { margin-top: 6px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.po-v2 .actlog-truncate {
  font-family: var(--font-sans); font-size: 11px; color: var(--muted);
  font-weight: 500; margin-top: 4px;
}
.po-v2 .actlog-reason { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.po-v2 .actlog-reason .reason-label { font-weight: 700; color: var(--ink); }
.po-v2 .actlog-reason.quote { font-style: italic; }

.po-v2 .actlog-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
}
.po-v2 .actlog-toolbar h2 { font-size: 17px; font-weight: 700; margin: 0; color: var(--ink); }
.po-v2 .actlog-toolbar-filters { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.po-v2 .actlog-toolbar select,
.po-v2 .actlog-toolbar input[type="search"] {
  padding: 6px 10px; font-size: 12px; border: 1px solid var(--border);
  border-radius: 6px; background: #fff; font-family: var(--font-sans);
}
.po-v2 .actlog-toolbar input[type="search"] { min-width: 220px; }
.po-v2 .actlog-empty,
.po-v2 .actlog-empty-search {
  padding: 32px 0; text-align: center; color: var(--muted); font-size: 13px;
}

/* Pager for lazy-loaded activity / receiving log Turbo Frames. */
.po-v2 .po-log-pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 4px 4px;
  border-top: 1px solid var(--border-light); margin-top: 8px;
}
.po-v2 .po-log-pager__link {
  font-size: 12px; font-weight: 600; color: var(--ink);
  text-decoration: none; padding: 6px 10px;
  border: 1px solid var(--border); border-radius: 6px; background: #fff;
  transition: all 0.12s;
}
.po-v2 .po-log-pager__link:hover { border-color: var(--ink); }
.po-v2 .po-log-pager__link.is-disabled {
  color: var(--light); cursor: default; background: var(--surface-alt);
}
.po-v2 .po-log-pager__link.is-disabled:hover { border-color: var(--border); }
.po-v2 .po-log-pager__meta { font-size: 12px; color: var(--muted); }

/* ---------- RECEIVING LOG ---------- */
.po-v2 table.recvlog { width: 100%; border-collapse: collapse; font-size: 13px; }
.po-v2 table.recvlog thead th {
  background: var(--surface-alt); color: var(--muted); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.6px; padding: 11px 14px;
  border-bottom: 1px solid var(--border); text-align: left;
}
.po-v2 table.recvlog tbody td { padding: 12px 14px; border-bottom: 1px solid var(--row-divider); }
.po-v2 table.recvlog tbody tr:last-child td { border-bottom: none; }
.po-v2 table.recvlog tr.inactive { color: var(--muted); }
.po-v2 table.recvlog tr.inactive .qty-num { text-decoration: line-through; }
.po-v2 .undo-btn {
  font: inherit; font-size: 11px; font-weight: 600; padding: 4px 10px;
  border-radius: 5px; border: 1px solid var(--border); background: #fff;
  color: var(--muted); cursor: pointer;
}
.po-v2 .undo-btn:hover { border-color: var(--red); color: var(--red); }
.po-v2 .undo-meta { font-size: 11px; color: var(--muted); font-style: italic; }

/* ============================================================
   INDEX PAGE — list of POs with filters + supply plan card
   ============================================================ */
.po-v2.po-index { display: flex; flex-direction: column; gap: 14px; }
.po-v2 .po-index-header {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; padding: 0 4px; margin: 4px 0 6px;
}
.po-v2 .po-index-header h1 {
  font-size: 22px; font-weight: 700; letter-spacing: -0.3px; margin: 0;
  color: var(--ink);
}
.po-v2 .po-index-actions { display: flex; gap: 8px; }

/* Supply Plan card */
.po-v2 .po-supply-plan-card { padding: 16px 20px; }
.po-v2 .po-supply-plan-card__inner {
  display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap;
}
.po-v2 .po-supply-plan-card__copy { flex: 1; min-width: 280px; }
.po-v2 .po-supply-plan-card__copy h3 {
  font-size: 14px; font-weight: 700; margin: 0 0 4px; color: var(--ink);
}
.po-v2 .po-supply-plan-card__copy p {
  margin: 0 0 6px; color: var(--muted); font-size: 12px; line-height: 1.5;
}
.po-v2 .po-supply-plan-card__copy p b { color: var(--ink); }
.po-v2 .po-supply-plan-card__meta { font-size: 11px; }
.po-v2 .po-supply-plan-card__running {
  display: inline-flex; align-items: center; gap: 4px;
  color: var(--accent); font-weight: 600;
}

/* Filters card */
.po-v2 .po-filters-card { padding: 14px 18px; }
.po-v2 .po-filters-form { display: flex; flex-direction: column; gap: 12px; }
.po-v2 .po-filter-grid {
  display: grid; gap: 10px 16px;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.po-v2 .po-filter { display: flex; flex-direction: column; gap: 4px; }
.po-v2 .po-filter .lbl {
  font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px;
}
.po-v2 .po-filter__input {
  font: inherit; font-family: var(--font-sans); font-size: 13px;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%;
}
.po-v2 .po-filter__input:focus {
  outline: none; border-color: var(--ink); box-shadow: var(--shadow-focus);
}
.po-v2 .po-filter-actions {
  display: flex; gap: 6px; justify-content: flex-end;
  border-top: 1px solid var(--border-light); padding-top: 10px;
}

/* PO list table — slightly tighter than the line-item table on show. */
.po-v2 table.po-index-table tbody td { padding: 10px 14px; }
.po-v2 .po-index-num {
  font-family: var(--font-mono); font-size: 12px; font-weight: 600;
  color: var(--ink); text-decoration: none;
}
.po-v2 .po-index-num:hover { color: var(--accent); text-decoration: underline; }

/* Chip strip + My POs toggle live on the same row, pushed apart. */
.po-v2 .po-index-chip-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 0 4px; flex-wrap: wrap;
}

/* Quick-filter chips — preset shortcuts above the filters card. */
.po-v2 .po-index-chips {
  display: flex; flex-wrap: wrap; gap: 6px;
}

/* My POs toggle — segmented two-state. Composes with chips (independent dimension). */
.po-v2 .po-index-mine-toggle {
  display: inline-flex; padding: 3px;
  background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: 999px; gap: 2px;
}
.po-v2 .po-index-mine-toggle__btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  font-size: 12px; font-weight: 600; color: var(--muted);
  text-decoration: none; transition: all 0.12s; white-space: nowrap;
}
.po-v2 .po-index-mine-toggle__btn:hover { color: var(--ink); }
.po-v2 .po-index-mine-toggle__btn.on {
  background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.05);
}

/* Index table caption ("created by Matt" inline with assignee name). */
.po-v2 .po-index-caption { color: var(--muted); font-size: 11px; margin-left: 4px; }

/* Pagination — .po-v2 restyle of the global .pagination-bar partial. Sits above
   AND below the table. Chip-pill page numbers, accent-orange active page,
   tight typography to match the rest of the design language. */
.po-v2 .pagination-bar {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 10px 16px;
  background: var(--surface-alt); border: 1px solid var(--border-light);
  border-radius: 8px; margin: 8px 0;
}
.po-v2 .pagination-info {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.po-v2 .pagination-info strong { color: var(--ink); font-weight: 600; }

.po-v2 .pagination-pages { display: inline-flex; align-items: center; gap: 4px; }
.po-v2 .pagination-nav {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 6px;
  background: #fff; border: 1px solid var(--border);
  color: var(--ink); text-decoration: none; transition: all 0.12s;
}
.po-v2 .pagination-nav:hover { border-color: var(--ink); }
.po-v2 .pagination-nav.disabled {
  color: var(--light); background: transparent; border-color: var(--border-light);
  cursor: default; pointer-events: none;
}
.po-v2 .pagination-page {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 8px;
  border-radius: 6px; background: #fff; border: 1px solid var(--border);
  color: var(--ink); font-size: 12px; font-weight: 600; text-decoration: none;
  font-variant-numeric: tabular-nums;
  transition: all 0.12s;
}
.po-v2 .pagination-page:hover { border-color: var(--ink); }
.po-v2 .pagination-page.active {
  background: var(--accent); color: #fff; border-color: var(--accent);
  cursor: default;
}
.po-v2 .pagination-gap { color: var(--light); padding: 0 4px; font-size: 13px; }

.po-v2 .pagination-per-page {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--muted);
}
.po-v2 .pagination-per-page-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
}
.po-v2 .pagination-per-page-options { display: inline-flex; gap: 3px; }
.po-v2 .pagination-pill {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 999px;
  background: #fff; border: 1px solid var(--border);
  color: var(--muted); font-size: 11px; font-weight: 600;
  text-decoration: none; transition: all 0.12s;
  font-variant-numeric: tabular-nums;
}
.po-v2 .pagination-pill:hover { border-color: var(--border-hover); color: var(--ink); }
.po-v2 .pagination-pill.active {
  background: var(--ink); color: #fff; border-color: var(--ink); cursor: default;
}
.po-v2 .po-index-chip {
  display: inline-flex; align-items: center; padding: 5px 12px;
  border-radius: 999px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted);
  font-size: 12px; font-weight: 600; text-decoration: none;
  transition: all 0.12s; white-space: nowrap;
}
.po-v2 .po-index-chip:hover { border-color: var(--border-hover); color: var(--ink); }
.po-v2 .po-index-chip.on {
  background: var(--ink); color: #fff; border-color: var(--ink);
}
.po-v2 .po-index-chip.on:hover { background: #000; }
.po-v2 .po-index-chip__count {
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
  background: var(--surface-alt); color: var(--muted);
  padding: 0 6px; border-radius: 999px; margin-left: 6px;
}
.po-v2 .po-index-chip.on .po-index-chip__count {
  background: rgba(255, 255, 255, 0.18); color: #fff;
}

/* Sortable headers — column label + small ↑/↓/↕ arrow. The whole th becomes
   a link. Inactive columns show a faint ↕; active column highlights the arrow. */
.po-v2 table.po-index-table thead th a.po-sort-link {
  display: inline-flex; align-items: center; gap: 4px;
  color: inherit; text-decoration: none; font-weight: inherit;
  letter-spacing: inherit; text-transform: inherit;
}
.po-v2 table.po-index-table thead th a.po-sort-link:hover { color: var(--ink); }
.po-v2 table.po-index-table thead th a.po-sort-link.on { color: var(--ink); }
.po-v2 .po-sort-arrow {
  font-size: 11px; color: var(--light); font-weight: 400; line-height: 1;
}
.po-v2 .po-sort-arrow.on { color: var(--accent); font-weight: 700; }

/* % Received chip — green when complete, amber-ish progress, muted at zero. */
.po-v2 .po-pct {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  font-variant-numeric: tabular-nums; min-width: 42px; text-align: center;
}
.po-v2 .po-pct.po-pct-zero { color: var(--muted); background: var(--surface-alt); }
.po-v2 .po-pct.po-pct-low  { color: var(--red);   background: var(--bg-oos);     border: 1px solid #fecaca; }
.po-v2 .po-pct.po-pct-mid  { color: var(--amber); background: var(--bg-low);     border: 1px solid #fde68a; }
.po-v2 .po-pct.po-pct-done { color: var(--green); background: var(--bg-healthy); border: 1px solid #86efac; }

/* ============================================================
   MODALS — generic .po-modal pattern
   Used by: reject modal (show page) + SKU search modal (edit page).
   Rendered inside .po-v2 — position:fixed handles overlay z-index.
   ============================================================ */
.po-modal { position: fixed; inset: 0; z-index: 1000; }
.po-modal__backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.5); }
.po-modal__panel {
  position: relative; margin: 10vh auto 0; max-width: 560px; width: 90vw;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12); overflow: hidden;
}
.po-modal__panel.po-modal__panel--wide { max-width: 720px; }
.po-modal__header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--border-light);
}
.po-modal__title { font-size: 16px; font-weight: 700; margin: 0; }
.po-modal__close {
  background: transparent; border: none; font-size: 18px;
  color: var(--muted); cursor: pointer; padding: 4px 8px;
}
.po-modal__body { padding: 16px 20px 20px; }
.po-modal__subtitle { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.po-modal__copy { font-size: 14px; color: var(--ink); margin: 0 0 16px; line-height: 1.5; }
.po-modal__label { display: block; font-size: 12px; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.po-modal__required { color: var(--muted); font-weight: 400; }
.po-modal__textarea {
  width: 100%; padding: 8px 10px; font-size: 14px;
  border: 1px solid var(--border); border-radius: 6px; resize: vertical;
}
.po-modal__textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 2px rgba(26,26,26,0.08); }
.po-modal__actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* SKU search modal extras (typeahead input + result list) */
.po-modal__search input[type="text"] {
  width: 100%; font: inherit; font-size: 13px;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--ink);
}
.po-modal__search input[type="text"]:focus {
  outline: none; border-color: var(--ink); box-shadow: 0 0 0 2px rgba(26,26,26,0.08);
}
.po-modal__hint { font-size: 11px; color: var(--muted); margin: 0 0 8px; line-height: 1.5; }
.po-modal__results {
  margin-top: 12px; max-height: 360px; overflow-y: auto;
  border: 1px solid var(--border-light); border-radius: 6px;
}
.po-modal__results .po-modal__empty {
  padding: 32px 12px; text-align: center; color: var(--muted); font-size: 13px;
}
.po-modal__result-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.po-modal__result-row:last-child { border-bottom: none; }
.po-modal__result-row.is-selected { background: var(--surface-alt); }
.po-modal__result-row label {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  cursor: pointer; margin: 0;
}
.po-modal__result-row .info { min-width: 0; flex: 1; }
.po-modal__result-row code {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink);
  background: var(--surface-alt); padding: 1px 6px; border-radius: 4px;
}
.po-modal__result-row .desc { color: var(--ink); margin-left: 8px; }
.po-modal__result-row .variant { color: var(--muted); margin-left: 6px; font-size: 12px; }

/* ============================================================
   EDIT-PAGE-ONLY PATTERNS
   Inputs that render inside table cells, the editable header
   meta grid, the form-errors banner, transfer nudge, empty
   state, and the bottom action row.
   Show page never renders these elements.
   ============================================================ */

/* Slim cell-level inputs (qty / unit_cost / ETA) */
.po-v2 .li-cell-input {
  font: inherit; font-family: var(--font-sans); font-size: 13px;
  padding: 5px 8px; border: 1px solid var(--border); border-radius: 5px;
  background: #fff; color: var(--ink); width: 100%; max-width: 100%;
}
.po-v2 .li-cell-input.num {
  font-family: var(--font-mono); text-align: right;
  font-variant-numeric: tabular-nums;
}
.po-v2 .li-cell-input:hover { border-color: var(--border-hover); }
.po-v2 .li-cell-input:focus {
  outline: none; border-color: var(--ink); box-shadow: var(--shadow-focus);
}
.po-v2 .li-cell-input[type="date"] { font-family: var(--font-mono); font-size: 12px; }
.po-v2 td.actions-col { width: 44px; text-align: center; }

/* ── Edit-page header grid ────────────────────────────────────────────────
   4-column × 2-row grid:
     row 1: Total | Vendor | Location | Created  (one field per col)
     row 2: Vendor Note (cols 1–2) | Internal Notes (cols 3–4)
   Replaces the show page's .po-h-meta + .po-h-notes pair on edit. */
.po-v2 .po-h-grid {
  display: grid; grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px 24px;
  margin-top: 18px; padding-top: 18px;
  border-top: 1px solid var(--border-light);
}
.po-v2 .po-h-grid__field {
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.po-v2 .po-h-grid__field--wide { grid-column: span 2; }

/* Reuse label + value typography from .po-h-meta. */
.po-v2 .po-h-grid .lbl {
  display: block; font-size: 10px; font-weight: 700; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.6px; margin-bottom: 2px;
}
.po-v2 .po-h-grid .val { font-size: 14px; font-weight: 600; color: var(--ink); }
.po-v2 .po-h-grid .val.mono { font-family: var(--font-mono); }
.po-v2 .po-h-grid .val .sub { font-size: 11px; color: var(--muted); font-weight: 500; margin-left: 4px; }

/* Form controls (selects, inputs, textareas) all share one consistent treatment. */
.po-v2 .po-h-grid select,
.po-v2 .po-h-grid input.po-h-input {
  font: inherit; font-family: var(--font-sans); font-size: 14px; font-weight: 600;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%;
}
.po-v2 .po-h-grid textarea {
  font: inherit; font-family: var(--font-sans); font-size: 13px;
  padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px;
  background: #fff; color: var(--ink); width: 100%;
  min-height: 64px; resize: vertical; line-height: 1.5;
}
.po-v2 .po-h-grid select:focus,
.po-v2 .po-h-grid input.po-h-input:focus,
.po-v2 .po-h-grid textarea:focus {
  outline: none; border-color: var(--ink); box-shadow: var(--shadow-focus);
}
/* Defeat browser autofill tinting so Vendor Note + Internal Notes always match. */
.po-v2 .po-h-grid textarea:-webkit-autofill,
.po-v2 .po-h-grid textarea:-webkit-autofill:hover,
.po-v2 .po-h-grid textarea:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #fff inset;
  -webkit-text-fill-color: var(--ink);
  caret-color: var(--ink);
}

/* Form errors banner — red counterpart of .banner-warn.
   The display: flex on these banners overrides the UA default [hidden] {display:none},
   so we re-add an explicit [hidden] rule to keep the empty banner placeholder
   actually hidden until JS populates it. */
.po-v2 .banner-error {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--bg-oos); border-top: 1px solid #fecaca; border-bottom: 1px solid #fecaca;
  padding: 12px 24px; font-size: 13px; line-height: 1.5; color: #991b1b;
}
.po-v2 .banner-error svg { width: 16px; height: 16px; flex-shrink: 0; margin-top: 1px; color: var(--red); }
.po-v2 .banner-error b { color: #7f1d1d; }
.po-v2 .banner-error ul { margin: 4px 0 0; padding-left: 18px; }
.po-v2 .banner-error[hidden],
.po-v2 .banner-warn[hidden] { display: none; }

/* Transfer nudge row — "consider transfer instead of PO" hint after Add Line Item */
.po-v2 tr.transfer-nudge td {
  background: var(--bg-low); border-left: 3px solid var(--amber);
  border-bottom: 1px solid var(--border-light);
  padding: 8px 14px 8px 24px; font-size: 12px; color: #78350f; line-height: 1.4;
}
.po-v2 tr.transfer-nudge td b { color: var(--ink); font-weight: 600; }
.po-v2 tr.transfer-nudge td a { color: var(--blue); text-decoration: underline; font-weight: 600; }

/* Empty state inside .li-card */
.po-v2 .li-empty {
  padding: 48px 24px; text-align: center; color: var(--muted);
  font-size: 13px; background: #fff; border-top: 1px solid var(--border-light);
}

/* Bottom action row (mirrors header .po-h-actions; .po-sec wrapper handles padding) */
.po-v2 .li-foot-actions {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 16px 24px; border-top: 1px solid var(--border-light); background: #fafaf7;
}
.po-v2 .li-foot-actions .right { display: flex; gap: 6px; }
.po-v2 .li-foot-actions form { display: inline-flex; }

/* Per-row remove button (× icon, danger on hover) */
.po-v2 .btn-row-remove {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0; border-radius: 5px;
  background: transparent; border: 1px solid transparent;
  color: var(--muted); cursor: pointer; transition: all 0.12s;
}
.po-v2 .btn-row-remove svg { width: 13px; height: 13px; }
.po-v2 .btn-row-remove:hover { background: var(--bg-oos); color: var(--red); border-color: #fecaca; }

/* Per-row undo button — only visible when the row is in pending-delete state. */
.po-v2 .btn-row-undo {
  display: none; align-items: center; gap: 4px;
  height: 26px; padding: 0 8px; border-radius: 5px;
  background: transparent; border: 1px solid var(--border);
  color: var(--blue); cursor: pointer; transition: all 0.12s;
  font: inherit; font-size: 11px; font-weight: 600;
}
.po-v2 .btn-row-undo svg { width: 11px; height: 11px; }
.po-v2 .btn-row-undo:hover { background: #eff6ff; border-color: var(--blue); }

/* Pending-delete row state — row stays in DOM, gets struck-through, the
   X button hides + the Undo button shows. The hidden removed_line_item_ids[]
   input drives the actual server-side delete on Save. Inputs are disabled in JS
   so they don't submit (and unpersisted rows don't accidentally re-create). */
.po-v2 tr.is-pending-delete td {
  background: var(--surface-alt);
}
.po-v2 tr.is-pending-delete .sku-name,
.po-v2 tr.is-pending-delete .sku-code,
.po-v2 tr.is-pending-delete .qty-num,
.po-v2 tr.is-pending-delete .li-cell-input {
  text-decoration: line-through;
  color: var(--muted);
}
.po-v2 tr.is-pending-delete .li-cell-input,
.po-v2 tr.is-pending-delete .li-cell-input.is-eta-missing {
  background: transparent; border-color: transparent;
}
.po-v2 tr.is-pending-delete .sku-copy { display: none; }
.po-v2 tr.is-pending-delete .btn-row-remove { display: none; }
.po-v2 tr.is-pending-delete .btn-row-undo { display: inline-flex; }

/* Danger variant of secondary button (Remove All) */
.po-v2 .btn-secondary.danger { color: var(--red); border-color: #fecaca; }
.po-v2 .btn-secondary.danger:hover { background: var(--bg-oos); border-color: var(--red); }

/* Section divider that doesn't draw a top border (used between .po-h and .po-sec without doubling) */
.po-v2 .po-sec.li-section { padding: 0; }
.po-v2 .po-sec.li-section > .li-head { padding: 16px 24px 12px; }
.po-v2 .po-sec.li-section > .li-tools { padding: 0 24px 8px; }
