/* =============================================================================
   console.css — shared chrome for DMS Console direction pages
   (list + detail). Namespaces: .cons__ (list), .pid__ (detail),
   .pill / .match / .row / .td / .totals__* / .group-row / .lrow / .kpiseg
   (shared atoms).
   ============================================================================= */

/* ----------------------------------------------------------------------------
   LIST PAGE STYLES (.cons__ + shared atoms)
   ---------------------------------------------------------------------------- */

/* =============================================================================
   DMS list — "Console" direction.

   Visual thesis: this is an operations console, not a dashboard.
   - Segmented header bar replaces tile cluster (active segment = solid navy).
   - Grid sits on the page canvas — no surrounding card chrome.
   - Status pills are Stripe-style: tinted bg + same-family text, sharp 5px radius.
   - Currency reads like a financial statement (15px mono, right-aligned).
   - Selected rows get a 4px navy accent + light blue fill.
   - Bulk bar is a small floating dark capsule, viewport-bottom, sticky to action.

   All colors via existing --sd- tokens. The body cancels the global
   app body padding so we own the layout completely.
   ============================================================================= */

.cons {
  padding: 22px 32px 96px;
  background: var(--sd-bg-app);
  min-height: 100%;
}

/* ---- breadcrumb ---------------------------------------------------------- */

/* =============================================================================
   SEGMENTED KPI HEADER — single connected bar
   Each segment carries severity via a 3px colored left accent.
   Active segment: solid --sd-navy-900 bg, white text.
   ============================================================================= */
/* =============================================================================
   SEGMENTED KPI HEADER — compact "minimal bar" treatment
   Two-row grid: [pip + label + delta] / [count + meta + ₹value]
   ~62px tall (was ~118px). Severity colour lives in the pip + active stripe.
   Active segment fills with the module accent (navy / teal / blue).
   ============================================================================= */
.cons__segbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 16px;
  position: relative;
}
.cons__segbar[data-kpi-count="5"] { grid-template-columns: repeat(5, 1fr); }

.kpiseg {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 5px;
  padding: 13px 18px;
  text-align: left;
  background: #fff;
  border: none;
  border-right: 1px solid var(--sd-line-200);
  cursor: pointer;
  font: inherit;
  color: inherit;
  transition: background 150ms ease, color 150ms ease;
  min-width: 0;
  white-space: normal;
}
.kpiseg:last-child { border-right: none; }
.kpiseg:hover { background: var(--sd-bg-soft); }

.kpiseg--amber   { --kpiseg-accent: var(--sd-amber-500); }
.kpiseg--blue    { --kpiseg-accent: var(--sd-blue-600); }
.kpiseg--red     { --kpiseg-accent: var(--sd-red-600); }
.kpiseg--green   { --kpiseg-accent: var(--sd-green-600); }
.kpiseg--neutral { --kpiseg-accent: var(--sd-ink-300); }

/* row 1: square pip + label + delta — full width of the segment */
.kpiseg__title {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 500;
  color: var(--sd-ink-700);
  letter-spacing: 0;
  text-transform: none;
  margin: 0;
  min-height: 0;
  line-height: 1.2;
  white-space: nowrap;
}
.kpiseg__title::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--kpiseg-accent, var(--sd-ink-200));
  flex-shrink: 0;
  transition: background 150ms ease;
}
.kpiseg__title > span:first-child {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  font-weight: 500;
  color: var(--sd-ink-700);
  letter-spacing: 0;
  text-transform: none;
}
.kpiseg__delta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 1px;
  font-family: var(--sd-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--sd-ink-500);
  letter-spacing: 0;
  text-transform: none;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.kpiseg__delta svg { width: 9px; height: 9px; }
/* delta colours unchanged: --bad amber, --good green */
.kpiseg__delta--up,
.kpiseg__delta--bad   { color: var(--sd-amber-text); }
.kpiseg__delta--down,
.kpiseg__delta--good  { color: #1F5E2A; }

/* row 2: count (left) + meta (middle, ellipsis) + ₹value (right) */
.kpiseg__count {
  grid-column: 1;
  grid-row: 2;
  align-self: baseline;
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--sd-ink-900);
  margin: 0;
}
.kpiseg__meta {
  grid-column: 2;
  grid-row: 2;
  align-self: baseline;
  font-size: 11.5px;
  color: var(--sd-ink-400);
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.kpiseg__value {
  grid-column: 3;
  grid-row: 2;
  align-self: baseline;
  justify-self: end;
  font-family: var(--sd-mono);
  font-size: 11.5px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--sd-ink-500);
  line-height: 1;
  text-align: right;
  white-space: nowrap;
}

/* active segment — solid module-coloured fill (navy / teal / blue), white text */
.kpiseg.is-active {
  background: var(--sd-navy-900);
  color: #fff;
}
.kpiseg.is-active .kpiseg__title,
.kpiseg.is-active .kpiseg__title > span:first-child { color: #fff; }
.kpiseg.is-active .kpiseg__count { color: #fff; }
.kpiseg.is-active .kpiseg__meta  { color: rgba(255,255,255,.65); }
.kpiseg.is-active .kpiseg__value { color: rgba(255,255,255,.85); }
.kpiseg.is-active .kpiseg__delta { color: rgba(255,255,255,.7); }
.kpiseg.is-active .kpiseg__delta--up,
.kpiseg.is-active .kpiseg__delta--bad  { color: var(--sd-amber-500); }
.kpiseg.is-active .kpiseg__delta--down,
.kpiseg.is-active .kpiseg__delta--good { color: #5EDB87; }
/* on active the severity pip stays — gives a small inset of severity colour */
.kpiseg.is-active .kpiseg__title::before {
  box-shadow: 0 0 0 1px rgba(255,255,255,.18);
}

/* trend deltas can be hidden */
.cons[data-trend="off"] .kpiseg__delta { display: none; }

/* =============================================================================
   TOOLBAR — no card chrome, inline on page
   ============================================================================= */
.cons__toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.cons__search {
  flex: 1 1 auto;
  max-width: 420px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 6px;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.cons__search:focus-within {
  border-color: var(--sd-blue-600);
  box-shadow: 0 0 0 3px rgba(23,162,184,.18);
}
.cons__search svg { width: 15px; height: 15px; color: var(--sd-ink-400); flex-shrink: 0; }
.cons__search input {
  flex: 1; border: none; background: transparent; outline: none;
  font: inherit; font-size: 13.5px; color: var(--sd-ink-900);
}
.cons__search input::placeholder { color: var(--sd-ink-300); }
.cons__search-kbd {
  font-family: var(--sd-mono); font-size: 10.5px;
  padding: 2px 6px; border-radius: 3px;
  background: var(--sd-bg-soft); color: var(--sd-ink-500);
}

.cons__spacer { flex: 1; }

/* =============================================================================
   FILTER CHIP — V1 "quiet outline" canonical
   - Default:    white card, 1px line, ink-500 label
   - Date chip:  always reads as the search input (soft grey card) — passive,
                 a date range is always present and shouldn't compete for ink
   - Status set: border darkens to module colour, count badge fills module colour
   Filled-card style is reserved exclusively for the primary CTA.
   ============================================================================= */
.cons__chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 6px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--sd-ink-800);
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
}
.cons__chip:hover { border-color: var(--sd-ink-400); }
.cons__chip:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(23,162,184,.18); }
.cons__chip svg.lead { width: 14px; height: 14px; color: var(--sd-ink-500); }
.cons__chip svg.chev { width: 11px; height: 11px; color: var(--sd-ink-400); margin-left: 2px; }

/* status (and other categorical) chips — set: ink-700 border, mono count badge */
.cons__chip.is-set:not(.is-date) {
  border-color: var(--sd-ink-700);
  background: #fff;
  color: var(--sd-ink-900);
}
.cons__chip.is-set:not(.is-date):hover { border-color: var(--sd-ink-900); }
.cons__chip.is-set:not(.is-date) svg.lead { color: var(--sd-ink-700); }

/* date chip — neutral white card, keeps the calendar icon as the affordance */
.cons__chip.is-date {
  background: #fff;
  border-color: var(--sd-line-300);
  color: var(--sd-ink-800);
}
.cons__chip.is-date:hover {
  background: #fff;
  border-color: var(--sd-ink-400);
}
.cons__chip.is-date svg.lead  { color: var(--sd-ink-500); }
.cons__chip.is-date svg.chev  { color: var(--sd-ink-400); }

/* count badge — module colour fill on set state */
.cons__chip-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-family: var(--sd-mono);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1;
  border-radius: 4px;
  background: var(--sd-navy-900);
  color: #fff;
  font-variant-numeric: tabular-nums;
}
.cons__chip > span { white-space: nowrap; }

/* primary toolbar CTA — Upload invoice */
.cons__primary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  background: var(--sd-navy-900);
  color: #fff;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 150ms ease;
  white-space: nowrap;
}
.cons__primary:hover { background: #0F1F36; }
.cons__primary svg { width: 14px; height: 14px; }

/* =============================================================================
   SAVED VIEW CHIPS
   ============================================================================= */
.cons__views {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.view-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 999px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--sd-ink-700);
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
  white-space: nowrap;
}
.view-chip:hover {
  border-color: var(--sd-ink-400);
  color: var(--sd-ink-900);
}
.view-chip.is-on {
  background: var(--sd-navy-900);
  border-color: var(--sd-navy-900);
  color: #fff;
}
.view-chip.is-on:hover { background: #0F1F36; }
.view-chip__label { line-height: 1; }
.view-chip__count {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-400);
  font-variant-numeric: tabular-nums;
  padding: 1px 5px;
  background: var(--sd-bg-soft);
  border-radius: 3px;
}
.view-chip.is-on .view-chip__count {
  color: #fff;
  background: rgba(255,255,255,.16);
}
.view-chip__dot {
  width: 6px; height: 6px;
  border-radius: 999px;
  background: var(--sd-ink-300);
}
.view-chip__dot--amber { background: var(--sd-amber-500); }
.view-chip__dot--red { background: var(--sd-red-600); }
.view-chip__dot--green { background: var(--sd-green-600); }
.view-chip__sep {
  width: 1px; height: 18px;
  background: var(--sd-line-200);
  margin: 0 4px;
}
.view-chip--ghost {
  border-style: dashed;
  color: var(--sd-ink-500);
}
.view-chip--ghost svg { width: 12px; height: 12px; }
.view-chip--ghost:hover {
  border-style: solid;
  border-color: var(--sd-blue-600);
  color: var(--sd-blue-600);
}

.cons__icon-btn {
  width: 38px; height: 38px;
  border: 1px solid var(--sd-line-300);
  background: #fff;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--sd-ink-500);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease;
}
.cons__icon-btn:hover { color: var(--sd-blue-600); border-color: var(--sd-blue-600); }
.cons__icon-btn svg { width: 16px; height: 16px; }

/* popover */
.cons__popover {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 8px;
  box-shadow: 0 14px 28px rgba(15,28,46,.15);
  padding: 14px;
  z-index: 20;
  display: none;
  min-width: 280px;
}
.cons__chip[data-popover-open="true"] .cons__popover { display: block; }
.cons__chip[data-popover-open="true"].is-date .cons__popover { display: flex; gap: 0; }

.cons__pop-presets {
  display: flex; flex-direction: column; gap: 1px;
  padding-right: 12px;
  border-right: 1px solid var(--sd-line-100);
}
.cons__pop-preset {
  text-align: left; background: none; border: none;
  padding: 7px 12px;
  border-radius: 4px;
  font: inherit;
  font-size: 13px; color: var(--sd-ink-700);
  font-weight: 400;
  cursor: pointer;
  white-space: nowrap;
}
.cons__pop-preset:hover { background: var(--sd-line-100); }
.cons__pop-preset.is-on {
  background: var(--sd-navy-900); color: #fff; font-weight: 500;
}
.cons__pop-custom { display: flex; flex-direction: column; gap: 10px; padding-left: 14px; min-width: 220px; }
.cons__pop-row { display: grid; grid-template-columns: 36px 1fr; align-items: center; gap: 8px; }
.cons__pop-row label {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--sd-ink-400);
}
.cons__pop-row input {
  height: 32px; padding: 0 10px;
  background: var(--sd-bg-soft); border: 1px solid var(--sd-line-300);
  border-radius: 4px;
  font: inherit; font-size: 13px; color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
}
.cons__pop-row input:focus { outline: none; border-color: var(--sd-blue-600); background: #fff; }
.cons__pop-actions { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }
.cons__pop-btn {
  height: 30px; padding: 0 14px;
  font: inherit; font-size: 12px; font-weight: 500;
  border-radius: 4px; cursor: pointer;
  border: 1px solid var(--sd-line-300);
  background: #fff; color: var(--sd-ink-700);
}
.cons__pop-btn--primary { background: var(--sd-navy-900); border-color: var(--sd-navy-900); color: #fff; }
.cons__pop-btn--primary:hover { background: #0F1F36; }
.cons__pop-list { display: flex; flex-direction: column; min-width: 260px; }
.cons__pop-search {
  display: flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 10px;
  background: var(--sd-bg-soft); border-radius: 4px; margin-bottom: 8px;
}
.cons__pop-search svg { width: 13px; height: 13px; color: var(--sd-ink-400); }
.cons__pop-search input { border: none; background: transparent; outline: none; font: inherit; font-size: 13px; flex: 1; }
.cons__pop-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 8px;
  border-radius: 4px; cursor: pointer;
  font-size: 13px; color: var(--sd-ink-800);
}
.cons__pop-opt:hover { background: var(--sd-line-100); }
.cons__pop-opt input[type="checkbox"] {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--sd-line-300);
  border-radius: 3px;
  background: #fff;
  cursor: pointer; position: relative; margin: 0;
}
.cons__pop-opt input[type="checkbox"]:checked {
  border-color: var(--sd-navy-900); background: var(--sd-navy-900);
}
.cons__pop-opt input[type="checkbox"]:checked::after {
  content: "";
  position: absolute; inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'><path d='M3.5 8.5 6.5 11.5 12.5 5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center;
}
.cons__pop-opt-count {
  margin-left: auto;
  font-family: var(--sd-mono); font-size: 11px;
  color: var(--sd-ink-400);
  font-variant-numeric: tabular-nums;
}
.cons__pop-divider { height: 1px; background: var(--sd-line-100); margin: 8px 0; }

/* =============================================================================
   GRID — sits on the canvas, no surrounding card
   ============================================================================= */
.cons__grid {
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  overflow: hidden;
}

/* sub-header strip — context line: counts + total + last refresh */

/* grid header */
.cons__head {
  display: flex; align-items: center;
  height: 40px;
  border-bottom: 1px solid var(--sd-line-200);
}
.cons__head .th {
  flex: 1 1 0;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
}
.cons__head .th--check {
  flex: 0 0 48px;
  display: flex; align-items: center; justify-content: center;
  padding: 0;
}
.cons__head .th--invoice { flex: 0 0 180px; }
.cons__head .th--date    { flex: 0 0 100px; }
.cons__head .th--po      { flex: 0 0 134px; }
.cons__head .th--branch  { flex: 0 0 124px; }
.cons__head .th--status  { flex: 0 0 140px; }
.cons__head .th--match   { flex: 0 0 134px; }
.cons__head .th--amount  { flex: 0 0 130px; text-align: right; }
.cons__head .th--action  { flex: 0 0 32px; }
/* supplier column is the flex column — give it a sensible minimum so the name
   doesn’t collapse to “RANE C…” at common viewport widths. */
.cons__head .th--supplier,
.row .td--supplier,
.cons__totals .td--supplier { flex: 1 1 0; min-width: 150px; }

/* row */
.cons__rows { position: relative; min-height: 280px; }
.row {
  display: flex; align-items: center;
  min-height: 56px;
  border-bottom: 1px solid var(--sd-line-100);
  position: relative;
  transition: background 100ms ease;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--sd-blue-050); }

.row .td {
  flex: 1 1 0;
  padding: 0 14px;
  font-size: 13.5px;
  color: var(--sd-ink-800);
  min-width: 0;
}
.row .td--check {
  flex: 0 0 48px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  align-self: stretch;
}
.row .td--invoice { flex: 0 0 180px; }
.row .td--date    { flex: 0 0 100px; }
.row .td--po      { flex: 0 0 134px; }
.row .td--branch  { flex: 0 0 124px; }
.row .td--status  { flex: 0 0 140px; }
.row .td--match   { flex: 0 0 134px; }
.row .td--amount  { flex: 0 0 130px; text-align: right; }
.row .td--action  { flex: 0 0 32px; }

/* sortable column header */
.th.is-sortable {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 150ms ease;
}
.th.is-sortable:hover { color: var(--sd-ink-900); }
.th.is-sortable .sort-ind {
  display: inline-flex;
  flex-direction: column;
  margin-left: 2px;
  opacity: 0;
  transition: opacity 150ms ease;
}
.th.is-sortable:hover .sort-ind,
.th.is-sorted .sort-ind { opacity: 1; }
.th .sort-ind svg {
  width: 7px;
  height: 5px;
  color: var(--sd-ink-300);
  display: block;
}
.th.is-sorted { color: var(--sd-ink-900); }
.th.is-sorted[data-sort="desc"] .sort-ind svg.s-down { color: var(--sd-navy-900); }
.th.is-sorted[data-sort="asc"] .sort-ind svg.s-up  { color: var(--sd-navy-900); }
.cons__head .th--amount.is-sortable { justify-content: flex-end; }

/* row is clickable */
.row { cursor: pointer; }
.row .td--check,
.row .td--po,
.row .td--action { cursor: default; }
.row.is-previewing { background: var(--sd-blue-050); }
.row.is-previewing::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--sd-teal-600);
}

/* primary field — Invoice no + sub */
.row .inv-no {
  font-size: 14px;
  font-weight: 500;
  color: var(--sd-ink-900);
  line-height: 1.25;
  display: block;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.005em;
}
.row .inv-sub {
  font-size: 12px;
  color: var(--sd-ink-500);
  line-height: 1.25;
  display: block;
  margin-top: 2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.row .td--date {
  font-size: 13px;
  color: var(--sd-ink-700);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.row .po-ref {
  font-family: var(--sd-mono);
  font-size: 12.5px;
  color: var(--sd-blue-600);
  text-decoration: none;
  white-space: nowrap;
}
.row:hover .po-ref { text-decoration: underline; text-underline-offset: 2px; }

.row .supplier__name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--sd-ink-800);
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* currency cell — financial statement feel */
.row .amt {
  font-family: var(--sd-mono);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* row selected — 4px navy accent + blue-100 fill */
.row.is-selected {
  background: var(--sd-blue-100);
}
.row.is-selected::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--sd-navy-900);
}

/* checkbox */
.row-check, .head-check {
  appearance: none;
  width: 16px; height: 16px;
  border: 1.5px solid var(--sd-line-300);
  border-radius: 3px;
  background: #fff;
  cursor: pointer; position: relative; margin: 0;
}
.row-check:hover { border-color: var(--sd-navy-900); }
.row-check:checked,
.head-check:checked {
  border-color: var(--sd-navy-900);
  background: var(--sd-navy-900);
}
.row-check:checked::after,
.head-check:checked::after {
  content: "";
  position: absolute; inset: 0;
  background: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'><path d='M3.5 8.5 6.5 11.5 12.5 5' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/></svg>") no-repeat center;
}
.head-check.is-indeterminate { background: var(--sd-navy-900); border-color: var(--sd-navy-900); }
.head-check.is-indeterminate::after {
  content: "";
  position: absolute; inset: 4px 2px;
  background: #fff;
  border-radius: 1px;
}

/* status pills — Stripe-style chunky tinted */
.td--status {
  display: flex;
  align-items: center;
  gap: 8px;
}
.pill-age {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-amber-text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.pill-age--stale { color: var(--sd-red-600); }
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.pill__icon { width: 11px; height: 11px; flex-shrink: 0; }
.pill.s-pending   { background: var(--sd-amber-100); color: var(--sd-amber-text); }
.pill.s-posted    { background: var(--sd-blue-100);  color: var(--sd-blue-700); }
.pill.s-confirmed { background: var(--sd-green-100); color: #1F5E2A; }
.pill.s-disputed  { background: var(--sd-red-100);   color: #8B2A2A; }
.pill.s-draft     { background: var(--sd-line-100);  color: var(--sd-ink-500); }
.pill.s-cancelled { background: var(--sd-line-100);  color: var(--sd-ink-400); text-decoration: line-through; text-decoration-thickness: 1px; }

/* 3-way match — segmented meter */
.match {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 12px;
  color: var(--sd-ink-700);
  font-weight: 500;
  white-space: nowrap;
}
.match__label { white-space: nowrap; }
.match__bars { display: flex; gap: 2px; }
.match__bar { width: 12px; height: 6px; border-radius: 1px; background: var(--sd-line-200); }
.match.is-3-3 .match__bar { background: var(--sd-green-600); }
.match.is-2-3 .match__bar:nth-child(-n+2) { background: var(--sd-amber-500); }
.match.is-1-3 .match__bar:nth-child(-n+1) { background: var(--sd-red-600); }
.match.is-mismatch .match__bar { background: var(--sd-red-600); }
.match.is-0-3 .match__bar { background: var(--sd-ink-200); }
.match.is-3-3 .match__label { color: #1F5E2A; }
.match.is-2-3 .match__label { color: var(--sd-amber-text); }
.match.is-1-3 .match__label,
.match.is-mismatch .match__label { color: #8B2A2A; }

/* row tail open arrow */
.row-arrow {
  display: inline-flex;
  width: 24px; height: 24px;
  border-radius: 4px;
  align-items: center; justify-content: center;
  color: var(--sd-ink-400);
  opacity: 0;
  transition: opacity 150ms ease, background 150ms ease, color 150ms ease;
}
.row:hover .row-arrow,
.row.is-selected .row-arrow { opacity: 1; }
.row .row-arrow:hover {
  background: var(--sd-navy-900);
  color: #fff;
}
.row-arrow svg { width: 12px; height: 12px; }

/* pager */

/* =============================================================================
   BULK BAR — small floating dark capsule
   ============================================================================= */
.cons__bulk {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(140%);
  display: flex; align-items: center; gap: 10px;
  padding: 8px 8px 8px 18px;
  background: var(--sd-navy-900);
  border-radius: 999px;
  color: #fff;
  box-shadow: 0 18px 40px rgba(15,28,46,.30), 0 0 0 1px rgba(255,255,255,.06) inset;
  z-index: 30;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,.7,.2,1);
}
.cons[data-state="bulk"] .cons__bulk {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.bulk__col {
  display: flex; align-items: baseline; gap: 6px;
  flex-shrink: 0; white-space: nowrap;
}
.bulk__count {
  font-size: 18px; font-weight: 600;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.bulk__label { font-size: 13px; color: rgba(255,255,255,.65); }
.bulk__sep { width: 1px; height: 18px; background: rgba(255,255,255,.16); }
.bulk__total {
  font-family: var(--sd-mono);
  font-size: 14px; font-weight: 500;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.bulk__btn {
  height: 34px;
  padding: 0 14px;
  font: inherit; font-size: 13px; font-weight: 500;
  border-radius: 999px;
  border: none;
  background: rgba(255,255,255,.10);
  color: #fff;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  transition: background 120ms ease;
}
.bulk__btn:hover { background: rgba(255,255,255,.18); }
.bulk__btn svg { width: 13px; height: 13px; }
.bulk__btn--primary {
  background: var(--sd-blue-600);
  font-weight: 600;
  padding: 0 16px;
}
.bulk__btn--primary:hover { background: var(--sd-blue-700); }
.bulk__btn--danger:hover { background: var(--sd-red-600); }
.bulk__close {
  width: 34px; height: 34px;
  background: transparent;
  border: none;
  color: rgba(255,255,255,.55);
  cursor: pointer;
  border-radius: 999px;
  display: inline-flex; align-items: center; justify-content: center;
}
.bulk__close:hover { color: #fff; background: rgba(255,255,255,.10); }
.bulk__close svg { width: 14px; height: 14px; }

/* =============================================================================
   STATES — empty / loading / error
   ============================================================================= */
.cons__state {
  display: none;
  padding: 80px 32px;
  text-align: center;
}
.cons[data-state="empty"]   .cons__state--empty   { display: block; }
.cons[data-state="loading"] .cons__state--loading { display: block; }
.cons[data-state="error"]   .cons__state--error   { display: block; }
.cons[data-state="empty"]   .cons__rows .row,
.cons[data-state="loading"] .cons__rows .row,
.cons[data-state="error"]   .cons__rows .row,
.cons[data-state="empty"]   .cons__substrip,
.cons[data-state="loading"] .cons__substrip,

.cons__state-art { width: 140px; height: 112px; margin: 0 auto 22px; }
.cons__state-title { font-size: 19px; font-weight: 600; color: var(--sd-ink-900); margin-bottom: 8px; letter-spacing: -0.01em; }
.cons__state-body { font-size: 14px; color: var(--sd-ink-500); max-width: 400px; margin: 0 auto 22px; line-height: 1.5; }
.cons__state-cta-row { display: inline-flex; align-items: center; gap: 8px; }
.cons__state-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 16px;
  height: 38px;
  background: var(--sd-navy-900);
  color: #fff;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.cons__state-cta:hover { background: #0F1F36; }
.cons__state-cta svg { width: 14px; height: 14px; }
.cons__state-cta--ghost {
  background: transparent;
  color: var(--sd-ink-700);
  border: 1px solid var(--sd-line-300);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 13px;
}
.cons__state-cta--ghost:hover { background: var(--sd-line-100); color: var(--sd-ink-900); }

/* loading skeleton */
.cons__skel { padding: 0; }
.cons__skel-row {
  display: flex; align-items: center; min-height: 56px;
  border-bottom: 1px solid var(--sd-line-100);
}
.cons__skel-row > * { padding: 0 14px; }
.cons__skel-row > .sk-check {
  flex: 0 0 48px; padding: 0;
  display: flex; align-items: center; justify-content: center;
  align-self: stretch;
}
.cons__skel-row > .sk-check::before {
  content: ""; display: block;
  width: 16px; height: 16px;
  border-radius: 3px; background: var(--sd-line-200);
}
.sk-bar {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--sd-line-100) 0%, var(--sd-line-200) 50%, var(--sd-line-100) 100%);
  background-size: 200% 100%;
  animation: cons-skel 1.4s ease-in-out infinite;
}
@keyframes cons-skel { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.sk-1 { width: 70%; }
.sk-2 { width: 50%; }
.sk-3 { width: 85%; }

/* error */
.cons__state--error .cons__state-title { color: #8B2A2A; }
.cons__error-detail {
  display: inline-block;
  margin: 0 0 22px;
  padding: 10px 14px;
  background: var(--sd-red-100);
  border: 1px solid #F5C4CC;
  border-radius: 6px;
  font-family: var(--sd-mono);
  font-size: 12px;
  color: #5C1717;
}

/* Branch column rendering */
.row .branch__name {
  font-size: 13px;
  color: var(--sd-ink-800);
  font-weight: 500;
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row .branch__code {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-400);
  display: block;
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
}

/* =============================================================================
   PINNED FOOTER TOTALS ROW — AG Grid style
   ============================================================================= */
.cons__totals {
  display: flex;
  align-items: center;
  min-height: 48px;
  background: #fff;
  border-top: 2px solid var(--sd-line-300);
  position: relative;
}
.cons__totals .td {
  flex: 1 1 0;
  padding: 0 14px;
  font-size: 13px;
  color: var(--sd-ink-700);
  min-width: 0;
}
.cons__totals .td--check  { flex: 0 0 48px; padding: 0; }
.cons__totals .td--invoice { flex: 0 0 180px; }
.cons__totals .td--date    { flex: 0 0 100px; }
.cons__totals .td--po      { flex: 0 0 134px; }
.cons__totals .td--branch  { flex: 0 0 124px; }
.cons__totals .td--status  { flex: 0 0 140px; }
.cons__totals .td--match   { flex: 0 0 134px; }
.cons__totals .td--amount  { flex: 0 0 130px; text-align: right; }
.cons__totals .td--action  { flex: 0 0 32px; }
.totals__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
}
.totals__label .sigma {
  font-family: var(--sd-mono);
  font-size: 13px;
  color: var(--sd-ink-900);
  letter-spacing: 0;
}
.totals__count {
  font-family: var(--sd-mono);
  font-size: 12px;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
}
.amt--total {
  font-family: var(--sd-mono);
  font-size: 14.5px;
  font-weight: 700;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.totals__sub {
  font-size: 10.5px;
  color: var(--sd-ink-400);
  margin-top: 2px;
  font-family: var(--sd-font);
  letter-spacing: 0;
  text-transform: none;
  font-weight: 500;
  display: block;
}
.cons__totals.is-selection-mode {
  background: var(--sd-blue-050);
  border-top-color: var(--sd-navy-900);
}

/* =============================================================================
   GROUP-BY MODE (Branch grouping, AG Grid feel)
   ============================================================================= */
.group-row {
  display: flex;
  align-items: center;
  height: 42px;
  padding: 0 14px 0 16px;
  background: var(--sd-bg-soft);
  border-bottom: 1px solid var(--sd-line-200);
  border-top: 1px solid var(--sd-line-200);
  cursor: pointer;
  gap: 10px;
  font-size: 12.5px;
  color: var(--sd-ink-800);
  position: relative;
  white-space: nowrap;
}
.group-row > * { flex-shrink: 0; }
.group-row__spacer { flex: 1 1 auto; }
.group-row:hover { background: var(--sd-line-100); }
.group-row:first-child { border-top: none; }
.group-row__chev {
  width: 14px; height: 14px;
  color: var(--sd-ink-500);
  transition: transform 150ms ease;
  flex-shrink: 0;
}
.group-row.is-collapsed .group-row__chev { transform: rotate(-90deg); }
.group-row__name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--sd-ink-900);
}
.group-row__count {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-500);
  padding: 1px 6px;
  border-radius: 3px;
  background: #fff;
  border: 1px solid var(--sd-line-200);
  font-variant-numeric: tabular-nums;
}
.group-row__spacer { flex: 1; }
.group-row__sum {
  font-family: var(--sd-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
}
.group-row__sum-label {
  font-size: 11px;
  color: var(--sd-ink-400);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-right: 6px;
}
.cons[data-groupby="branch"] .row .td--invoice {
  padding-left: 30px;
}
.cons[data-groupby="branch"] .row.is-grp-hidden {
  display: none;
}
.cons[data-groupby="branch"] .row .td--branch {
  color: var(--sd-ink-400);
  font-size: 11px;
}

/* density modes (default = comfortable 56px / 13.5px) */
.cons[data-density="compact"] .row { min-height: 44px; }
.cons[data-density="compact"] .row .td { font-size: 12.5px; padding: 0 12px; }
.cons[data-density="compact"] .row .inv-no { font-size: 13px; }
.cons[data-density="compact"] .row .inv-sub { display: none; }
.cons[data-density="compact"] .row .amt { font-size: 13.5px; }
.cons[data-density="compact"] .cons__head { height: 36px; }
.cons[data-density="compact"] .cons__skel-row { min-height: 44px; }

/* side-panel preview slide-over */
.cons__preview {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 440px;
  max-width: 100vw;
  background: #fff;
  border-left: 1px solid var(--sd-line-300);
  box-shadow: -16px 0 32px rgba(15,28,46,.10);
  z-index: 80;
  transform: translateX(100%);
  transition: transform 220ms cubic-bezier(.2,.7,.2,1);
  display: flex;
  flex-direction: column;
}
.cons__preview.is-open { transform: translateX(0); }
.cons__preview-head {
  display: flex;
  align-items: center;
  height: 56px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sd-line-200);
  gap: 12px;
}
.cons__preview-title {
  flex: 1;
  font-size: 16px;
  font-weight: 600;
  color: var(--sd-ink-900);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  display: flex; flex-direction: column; gap: 2px;
}
.cons__preview-title small {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
  font-family: var(--sd-mono);
}
.cons__preview-close {
  width: 32px; height: 32px;
  background: transparent; border: 1px solid transparent;
  border-radius: 6px;
  color: var(--sd-ink-500);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.cons__preview-close:hover { background: var(--sd-line-100); color: var(--sd-ink-900); }
.cons__preview-close svg { width: 16px; height: 16px; }
.cons__preview-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.preview-sec { display: flex; flex-direction: column; gap: 10px; }
.preview-sec__label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
}
.preview-amt {
  font-family: var(--sd-mono);
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.preview-amt__sub {
  font-size: 12.5px;
  color: var(--sd-ink-500);
  margin-top: 6px;
  font-family: var(--sd-font);
  letter-spacing: 0;
}
.preview-grid {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 9px;
  column-gap: 14px;
  font-size: 13px;
}
.preview-grid dt { color: var(--sd-ink-500); }
.preview-grid dd {
  margin: 0;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
}
.preview-grid dd a { color: var(--sd-blue-600); text-decoration: none; font-family: var(--sd-mono); font-size: 12.5px; }
.preview-grid dd a:hover { text-decoration: underline; }
.preview-mini-table {
  border: 1px solid var(--sd-line-200);
  border-radius: 8px;
  overflow: hidden;
}
.preview-mini-row {
  display: grid;
  grid-template-columns: 1fr 50px 90px;
  padding: 10px 12px;
  font-size: 12.5px;
  border-bottom: 1px solid var(--sd-line-100);
  align-items: center;
  gap: 8px;
}
.preview-mini-row:last-child { border-bottom: none; }
.preview-mini-row.is-head {
  background: var(--sd-bg-soft);
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--sd-ink-500);
}
.preview-mini-row .q,
.preview-mini-row .a {
  text-align: right;
  font-family: var(--sd-mono);
  font-variant-numeric: tabular-nums;
  color: var(--sd-ink-900);
}
.preview-mini-row .name { color: var(--sd-ink-800); }
.preview-mini-foot {
  display: flex;
  justify-content: flex-end;
  padding: 8px 12px;
  font-size: 11.5px;
  color: var(--sd-ink-500);
  background: var(--sd-bg-soft);
  font-family: var(--sd-mono);
  font-variant-numeric: tabular-nums;
}
.cons__preview-foot {
  display: flex;
  gap: 8px;
  padding: 14px 20px;
  border-top: 1px solid var(--sd-line-200);
  background: var(--sd-bg-soft);
}
.preview-btn {
  flex: 1;
  height: 38px;
  padding: 0 14px;
  border-radius: 6px;
  border: 1px solid var(--sd-line-300);
  background: #fff;
  color: var(--sd-ink-800);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: border-color 150ms ease, color 150ms ease;
}
.preview-btn:hover { border-color: var(--sd-navy-900); color: var(--sd-ink-900); }
.preview-btn--primary {
  background: var(--sd-navy-900);
  border-color: var(--sd-navy-900);
  color: #fff;
}
.preview-btn--primary:hover { background: #0F1F36; color: #fff; }
.preview-btn svg { width: 13px; height: 13px; }
.cons__preview-scrim {
  position: fixed;
  inset: 0;
  background: rgba(15,28,46,.32);
  z-index: 70;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}
.cons__preview-scrim.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* match meter inside preview */
.preview-match {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--sd-line-200);
  border-radius: 8px;
  background: var(--sd-bg-soft);
}
.preview-match__row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
}
.preview-match__row svg { width: 14px; height: 14px; flex-shrink: 0; }
.preview-match__row .lbl { color: var(--sd-ink-700); flex: 1; }
.preview-match__row .val { font-family: var(--sd-mono); font-size: 11.5px; color: var(--sd-ink-500); font-variant-numeric: tabular-nums; white-space: nowrap; flex-shrink: 0; }
.preview-match__row.is-ok svg { color: var(--sd-green-600); }
.preview-match__row.is-warn svg { color: var(--sd-amber-500); }
.preview-match__row.is-bad svg { color: var(--sd-red-600); }
.preview-match__row.is-bad .val { color: var(--sd-red-600); font-weight: 600; }

/* =============================================================================
   TWEAKS PANEL
   ============================================================================= */
.cons-tweaks {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 280px;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(15,28,46,.15);
  z-index: 100;
  display: none;
}
.cons-tweaks.is-open { display: block; }
.cons-tweaks__head {
  display: flex; align-items: center;
  height: 40px; padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--sd-line-100);
}
.cons-tweaks__title { font-size: 13px; font-weight: 600; color: var(--sd-ink-900); flex: 1; }
.cons-tweaks__close {
  width: 28px; height: 28px;
  background: transparent; border: none; border-radius: 4px;
  color: var(--sd-ink-500); cursor: pointer;
}
.cons-tweaks__close:hover { background: var(--sd-line-100); color: var(--sd-ink-900); }
.cons-tweaks__body { padding: 12px 14px 14px; }
.cons-tweaks__sect { margin-bottom: 14px; }
.cons-tweaks__sect:last-child { margin-bottom: 0; }
.cons-tweaks__label {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--sd-ink-400); margin-bottom: 6px;
}
.cons-tweaks__radio { display: flex; background: var(--sd-bg-soft); border-radius: 6px; padding: 3px; gap: 2px; }
.cons-tweaks__radio button {
  flex: 1; height: 28px; border: none; background: transparent;
  border-radius: 4px;
  font: inherit; font-size: 12px; font-weight: 500; color: var(--sd-ink-500);
  cursor: pointer;
}
.cons-tweaks__radio button:hover { color: var(--sd-ink-900); }
.cons-tweaks__radio button.is-on { background: #fff; color: var(--sd-ink-900); box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.cons-tweaks__select {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--sd-line-300); border-radius: 4px;
  font: inherit; font-size: 13px; color: var(--sd-ink-900); background: #fff;
}
.cons-tweaks__toggle {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--sd-ink-800);
}
.cons-tweaks__switch {
  width: 32px; height: 18px;
  border-radius: 999px; background: var(--sd-line-300);
  position: relative; cursor: pointer; border: none; padding: 0;
}
.cons-tweaks__switch::after {
  content: ""; position: absolute;
  width: 14px; height: 14px; border-radius: 999px;
  background: #fff; top: 2px; left: 2px;
  transition: left 150ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.cons-tweaks__switch.is-on { background: var(--sd-navy-900); }
.cons-tweaks__switch.is-on::after { left: 16px; }

/* safety: stray svgs never blow up */
.cons svg { max-width: 100%; max-height: 100%; }

/* ----------------------------------------------------------------------------
   DETAIL PAGE STYLES (.pid__ + extra atoms)
   ---------------------------------------------------------------------------- */

/* =============================================================================
   Purchase invoice DETAIL — Console style, matches the list page.
   Namespace: .pid__ (purchase invoice detail). Reuses .pill, .match where useful.
   ============================================================================= */

.pid {
  padding: 22px 32px 96px;
  background: var(--sd-bg-app);
  min-height: 100%;
}

/* ---- list-nav strip (prev/next within filtered list) ----------------- */
.pid__listnav {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 32px;
  padding: 0 4px;
  margin-bottom: 16px;
  font-size: 12.5px;
  color: var(--sd-ink-500);
}
.pid__listnav-back {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--sd-ink-500); text-decoration: none;
  white-space: nowrap;
  transition: color 150ms ease;
}
.pid__listnav-back:hover { color: var(--sd-ink-900); }
.pid__listnav-back svg { width: 12px; height: 12px; }
.pid__listnav-spacer { flex: 1; min-width: 0; }

/* the tight [< | n of N | >] capsule */
.pid__listnav-nav {
  display: inline-flex;
  align-items: stretch;
  height: 26px;
  border: 1px solid var(--sd-line-300);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
  background: #fff;
}
.pid__listnav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  background: transparent;
  border: none;
  font: inherit;
  cursor: pointer;
  color: var(--sd-ink-500);
  transition: background 100ms ease, color 100ms ease;
  padding: 0;
}
.pid__listnav-btn:hover:not(:disabled) {
  background: var(--sd-line-100);
  color: var(--sd-ink-900);
}
.pid__listnav-btn:disabled {
  color: var(--sd-ink-300);
  cursor: not-allowed;
}
.pid__listnav-btn svg { width: 11px; height: 11px; flex-shrink: 0; }
.pid__listnav-pos {
  display: inline-flex;
  align-items: baseline;
  gap: 3px;
  padding: 0 10px;
  border-left: 1px solid var(--sd-line-200);
  border-right: 1px solid var(--sd-line-200);
  background: var(--sd-bg-soft);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--sd-ink-700);
  white-space: nowrap;
  align-self: stretch;
  align-items: center;
}
.pid__listnav-pos strong {
  color: var(--sd-ink-900);
  font-weight: 500;
}
.pid__listnav-pos .sep { color: var(--sd-ink-400); font-weight: 400; }

/* legacy / unused classes for back-compat */
.pid__listnav-divider,
.pid__listnav-kbd,
.pid__listnav-btn-id,
.pid__listnav-btn-cap,
.pid__listnav-btn-inner { display: none; }

/* keep this empty fallback for back-compat — older markup that used a .pid__back link */

/* ---- header ------------------------------------------------------------ */
.pid__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
  flex-wrap: wrap;
}
.pid__title-block { flex: 1 1 auto; min-width: 0; }
.pid__eyebrow {
  font-family: var(--sd-mono);
  font-size: 12px;
  color: var(--sd-ink-500);
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  white-space: nowrap;
}
.pid__eyebrow > span,
.pid__eyebrow > a { white-space: nowrap; }
.pid__eyebrow .sep { color: var(--sd-line-200); }
.pid__eyebrow a {
  color: var(--sd-blue-600);
  text-decoration: none;
}
.pid__eyebrow a:hover { text-decoration: underline; }
.pid__title {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--sd-ink-900);
  margin: 0 0 8px;
  line-height: 1.15;
}
.pid__meta {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--sd-ink-500);
  flex-wrap: wrap;
}
.pid__meta > span { white-space: nowrap; }
.pid__meta .sep {
  width: 3px; height: 3px;
  border-radius: 999px;
  background: var(--sd-line-300);
}

/* ---- header actions ---------------------------------------------------- */
.pid__actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.pid__btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 16px;
  border-radius: 6px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border: 1px solid var(--sd-line-300);
  background: #fff;
  color: var(--sd-ink-800);
  transition: border-color 150ms ease, background 150ms ease, color 150ms ease;
  white-space: nowrap;
}
.pid__btn:hover { border-color: var(--sd-navy-900); color: var(--sd-ink-900); }
.pid__btn svg { width: 13px; height: 13px; }
.pid__btn--danger { color: #8B2A2A; }
.pid__btn--danger:hover { border-color: var(--sd-red-600); background: var(--sd-red-100); color: #8B2A2A; }
.pid__btn--primary {
  background: var(--sd-navy-900);
  border-color: var(--sd-navy-900);
  color: #fff;
}
.pid__btn--primary:hover { background: #0F1F36; color: #fff; }
.pid__btn--icon { width: 38px; padding: 0; justify-content: center; }
.pid__btn--icon svg { width: 16px; height: 16px; }

/* status row inside meta */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 9px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.005em;
  white-space: nowrap;
}
.pill.s-pending   { background: var(--sd-amber-100); color: var(--sd-amber-text); }
.pill.s-posted    { background: var(--sd-blue-100);  color: var(--sd-blue-700); }
.pill.s-confirmed { background: var(--sd-green-100); color: #1F5E2A; }
.pill.s-disputed  { background: var(--sd-red-100);   color: #8B2A2A; }
.pill-age {
  font-family: var(--sd-mono);
  font-size: 11.5px;
  color: var(--sd-amber-text);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.pill-age--stale { color: var(--sd-red-600); }

/* =============================================================================
   SUMMARY TILES (small KPI row, no active state)
   ============================================================================= */
.pid__tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 22px;
}
.pid__tile {
  padding: 16px 20px;
  border-right: 1px solid var(--sd-line-200);
  position: relative;
}
.pid__tile:last-child { border-right: none; }
.pid__tile::before {
  content: "";
  position: absolute;
  left: 0; top: 14px; bottom: 14px;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--pid-tile-accent, var(--sd-ink-200));
}
.pid__tile--ok   { --pid-tile-accent: var(--sd-green-600); }
.pid__tile--info { --pid-tile-accent: var(--sd-blue-600); }
.pid__tile--warn { --pid-tile-accent: var(--sd-amber-500); }
.pid__tile--bad  { --pid-tile-accent: var(--sd-red-600); }
.pid__tile-label {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
  margin-bottom: 10px;
}
.pid__tile-value {
  font-family: var(--sd-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin-bottom: 6px;
}
.pid__tile-value--inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}
.pid__tile-value--inline .pid-match-mini {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.pid-match-mini__bar {
  width: 14px; height: 8px;
  border-radius: 1px;
  background: var(--sd-line-200);
}
.pid-match-mini__bar.is-ok  { background: var(--sd-green-600); }
.pid-match-mini__bar.is-bad { background: var(--sd-red-600); }
.pid__tile-sub {
  font-size: 12.5px;
  color: var(--sd-ink-500);
  line-height: 1.35;
}
.pid__tile-sub strong {
  color: var(--sd-ink-700);
  font-weight: 600;
}

/* =============================================================================
   LINE ITEMS GRID — AG Grid feel, matches list table style.
   Columns:
     #   Part   Description   HSN   Qty(inv/po)   Rate   Taxable   GST%   GST   Net
   ============================================================================= */
.pid__section-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
  margin: 28px 0 10px;
  white-space: nowrap;
}
.pid__section-title .count {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-700);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  text-transform: none;
  font-weight: 600;
}

.pid__grid {
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  overflow: hidden;
}

/* head */
.pid__head {
  display: flex;
  align-items: center;
  height: 40px;
  border-bottom: 1px solid var(--sd-line-200);
}
.pid__head .th {
  flex: 1 1 0;
  padding: 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
  white-space: nowrap;
}
.pid__head .th--num     { flex: 0 0 36px; padding: 0 10px; }
.pid__head .th--part    { flex: 0 0 124px; }
.pid__head .th--desc    { flex: 1 1 0; min-width: 200px; }
.pid__head .th--hsn     { flex: 0 0 100px; }
.pid__head .th--qty     { flex: 0 0 90px; text-align: right; }
.pid__head .th--rate    { flex: 0 0 92px; text-align: right; }
.pid__head .th--taxable { flex: 0 0 100px; text-align: right; }
.pid__head .th--taxpct  { flex: 0 0 60px; text-align: right; }
.pid__head .th--gst     { flex: 0 0 96px; text-align: right; }
.pid__head .th--net     { flex: 0 0 112px; text-align: right; }

/* sortable indicators (reuse list-style) */
.pid__head .th.is-sortable {
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color 150ms ease;
}
.pid__head .th.is-sortable:hover { color: var(--sd-ink-900); }
.pid__head .th--qty.is-sortable,
.pid__head .th--rate.is-sortable,
.pid__head .th--taxable.is-sortable,
.pid__head .th--gst.is-sortable,
.pid__head .th--net.is-sortable { justify-content: flex-end; }
.pid__head .sort-ind {
  display: inline-flex;
  flex-direction: column;
  margin-left: 2px;
  opacity: 0;
  transition: opacity 150ms ease;
}
.pid__head .th.is-sortable:hover .sort-ind,
.pid__head .th.is-sorted .sort-ind { opacity: 1; }
.pid__head .sort-ind svg { width: 7px; height: 5px; color: var(--sd-ink-300); display: block; }
.pid__head .th.is-sorted { color: var(--sd-ink-900); }
.pid__head .th.is-sorted[data-sort="desc"] .sort-ind svg.s-down { color: var(--sd-navy-900); }
.pid__head .th.is-sorted[data-sort="asc"] .sort-ind svg.s-up  { color: var(--sd-navy-900); }

/* row */
.pid__rows .lrow {
  display: flex;
  align-items: center;
  min-height: 54px;
  border-bottom: 1px solid var(--sd-line-100);
  transition: background 100ms ease;
}
.pid__rows .lrow:last-child { border-bottom: none; }
.pid__rows .lrow:hover { background: var(--sd-blue-050); }
.pid__rows .td {
  flex: 1 1 0;
  padding: 0 14px;
  font-size: 13px;
  color: var(--sd-ink-800);
  min-width: 0;
}
.pid__rows .td--num     { flex: 0 0 36px; padding: 0 10px; font-family: var(--sd-mono); font-size: 11.5px; color: var(--sd-ink-400); font-variant-numeric: tabular-nums; }
.pid__rows .td--part    { flex: 0 0 124px; font-family: var(--sd-mono); font-size: 12.5px; color: var(--sd-ink-900); font-variant-numeric: tabular-nums; }
.pid__rows .td--desc    { flex: 1 1 0; min-width: 200px; font-size: 13px; color: var(--sd-ink-900); }
.pid__rows .td--hsn     { flex: 0 0 100px; font-family: var(--sd-mono); font-size: 11.5px; color: var(--sd-ink-500); font-variant-numeric: tabular-nums; }
.pid__rows .td--qty     { flex: 0 0 90px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-800); font-size: 13px; }
.pid__rows .td--rate    { flex: 0 0 92px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-800); font-size: 13px; white-space: nowrap; }
.pid__rows .td--taxable { flex: 0 0 100px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-700); font-size: 13px; }
.pid__rows .td--taxpct  { flex: 0 0 60px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-500); font-size: 11.5px; }
.pid__rows .td--gst     { flex: 0 0 96px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-700); font-size: 13px; }
.pid__rows .td--net     { flex: 0 0 112px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-900); font-size: 14px; font-weight: 600; }

/* line description: title + small sub like rate-diff hint */
.lrow .desc__name {
  display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lrow .desc__hint {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--sd-red-600);
  font-weight: 500;
}
.lrow .qty__diff {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  color: var(--sd-ink-400);
}
.lrow .qty__diff--bad { color: var(--sd-red-600); }
.lrow .rate__diff {
  display: block;
  margin-top: 2px;
  font-size: 10.5px;
  color: var(--sd-red-600);
  font-weight: 500;
  white-space: nowrap;
}
.lrow.is-bad { background: rgba(226,66,96,.04); }
.lrow.is-bad::before {
  /* a faint left accent on problem lines */
}
.lrow .gst-pct-tag {
  display: inline-block;
  font-family: var(--sd-mono);
  font-size: 10.5px;
  font-weight: 600;
  color: var(--sd-ink-500);
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--sd-bg-soft);
  font-variant-numeric: tabular-nums;
}

/* pinned totals row */
.pid__totals {
  display: flex;
  align-items: center;
  min-height: 48px;
  background: #fff;
  border-top: 2px solid var(--sd-line-300);
}
.pid__totals .td {
  flex: 1 1 0;
  padding: 0 14px;
  font-size: 13px;
  color: var(--sd-ink-700);
  min-width: 0;
}
.pid__totals .td--num     { flex: 0 0 36px; padding: 0 10px; }
.pid__totals .td--part    { flex: 0 0 124px; }
.pid__totals .td--desc    { flex: 1 1 0; min-width: 200px; }
.pid__totals .td--hsn     { flex: 0 0 100px; }
.pid__totals .td--qty     { flex: 0 0 90px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--sd-ink-900); }
.pid__totals .td--rate    { flex: 0 0 92px; }
.pid__totals .td--taxable { flex: 0 0 100px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--sd-ink-900); font-size: 13px; }
.pid__totals .td--taxpct  { flex: 0 0 60px; }
.pid__totals .td--gst     { flex: 0 0 96px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; font-weight: 600; color: var(--sd-ink-900); font-size: 13px; }
.pid__totals .td--net     { flex: 0 0 112px; text-align: right; font-family: var(--sd-mono); font-variant-numeric: tabular-nums; font-weight: 700; color: var(--sd-ink-900); font-size: 14.5px; letter-spacing: -0.01em; }
.totals__label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
  white-space: nowrap;
}
.totals__label > * { flex-shrink: 0; }
.totals__label .sigma { font-family: var(--sd-mono); font-size: 13px; color: var(--sd-ink-900); letter-spacing: 0; }
.totals__label .totals__count {
  font-family: var(--sd-mono);
  font-size: 11px;
  color: var(--sd-ink-700);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: none;
  padding: 1px 6px;
  background: var(--sd-bg-soft);
  border-radius: 3px;
}

/* =============================================================================
   BOTTOM GRID — Invoice breakdown · Supplier · Activity
   ============================================================================= */
.pid__bottom {
  display: grid;
  grid-template-columns: minmax(360px, 1.1fr) minmax(260px, 0.9fr) minmax(320px, 1fr);
  gap: 18px;
  margin-top: 22px;
}
.pid__card {
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  padding: 18px 20px;
}
.pid__card-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-500);
  margin: 0 0 16px;
}

/* invoice breakdown */
.pid__breakdown { display: flex; flex-direction: column; gap: 9px; }
.pid__breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-size: 13px;
  color: var(--sd-ink-700);
  white-space: nowrap;
}
.pid__breakdown-row .lbl { color: var(--sd-ink-500); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.pid__breakdown-row .val { font-family: var(--sd-mono); font-variant-numeric: tabular-nums; color: var(--sd-ink-900); flex-shrink: 0; white-space: nowrap; }
.pid__breakdown-row--sub .lbl { font-size: 12px; color: var(--sd-ink-400); padding-left: 16px; }
.pid__breakdown-row--sub .val { color: var(--sd-ink-500); font-size: 12.5px; }
.pid__breakdown-divider {
  height: 1px;
  background: var(--sd-line-200);
  margin: 4px 0;
}
.pid__breakdown-row--grand {
  padding-top: 12px;
  border-top: 2px solid var(--sd-line-300);
  margin-top: 4px;
}
.pid__breakdown-row--grand .lbl {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-700);
}
.pid__breakdown-row--grand .val {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

/* supplier card */
.pid__sup-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--sd-ink-900);
  margin-bottom: 14px;
  letter-spacing: -0.005em;
}
.pid__sup-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 10px;
  padding: 6px 0;
  font-size: 12.5px;
  margin: 0;
}
.pid__sup-row dt { color: var(--sd-ink-500); white-space: nowrap; }
.pid__sup-row dd {
  margin: 0;
  color: var(--sd-ink-900);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
}
.pid__sup-row dd.mono {
  font-family: var(--sd-mono);
  font-size: 12px;
  color: var(--sd-ink-800);
}

/* activity */
.pid__activity { display: flex; flex-direction: column; }
.pid__act {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--sd-line-100);
  position: relative;
}
.pid__act:last-child { border-bottom: none; }
.pid__act-dot {
  width: 10px; height: 10px;
  border-radius: 999px;
  background: var(--sd-line-300);
  margin-top: 4px;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--sd-line-300);
}
.pid__act-dot--ok   { background: var(--sd-green-600); box-shadow: 0 0 0 1px var(--sd-green-600); }
.pid__act-dot--warn { background: var(--sd-amber-500); box-shadow: 0 0 0 1px var(--sd-amber-500); }
.pid__act-dot--bad  { background: var(--sd-red-600);   box-shadow: 0 0 0 1px var(--sd-red-600); }
.pid__act-dot--info { background: var(--sd-blue-600);  box-shadow: 0 0 0 1px var(--sd-blue-600); }
.pid__act-text {
  font-size: 13px;
  color: var(--sd-ink-800);
  line-height: 1.4;
}
.pid__act-text strong { color: var(--sd-ink-900); font-weight: 600; }
.pid__act-meta {
  font-size: 11.5px;
  color: var(--sd-ink-400);
  font-family: var(--sd-mono);
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

/* =============================================================================
   Tweaks (lightweight — single panel hidden by default)
   ============================================================================= */
.pid-tweaks {
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 260px;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 10px;
  box-shadow: 0 14px 28px rgba(15,28,46,.15);
  z-index: 100;
  display: none;
}
.pid-tweaks.is-open { display: block; }
.pid-tweaks__head {
  display: flex; align-items: center;
  height: 40px; padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--sd-line-100);
}
.pid-tweaks__title { font-size: 13px; font-weight: 600; color: var(--sd-ink-900); flex: 1; }
.pid-tweaks__close {
  width: 28px; height: 28px;
  background: transparent; border: none; border-radius: 4px;
  color: var(--sd-ink-500); cursor: pointer;
}
.pid-tweaks__close:hover { background: var(--sd-line-100); color: var(--sd-ink-900); }
.pid-tweaks__body { padding: 12px 14px 14px; }
.pid-tweaks__sect { margin-bottom: 14px; }
.pid-tweaks__sect:last-child { margin-bottom: 0; }
.pid-tweaks__label {
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--sd-ink-400); margin-bottom: 6px;
}
.pid-tweaks__select {
  width: 100%; height: 34px; padding: 0 10px;
  border: 1px solid var(--sd-line-300); border-radius: 4px;
  font: inherit; font-size: 13px; color: var(--sd-ink-900); background: #fff;
}
.pid-tweaks__toggle {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--sd-ink-800);
}
.pid-tweaks__switch {
  width: 32px; height: 18px;
  border-radius: 999px; background: var(--sd-line-300);
  position: relative; cursor: pointer; border: none; padding: 0;
}
.pid-tweaks__switch::after {
  content: ""; position: absolute;
  width: 14px; height: 14px; border-radius: 999px;
  background: #fff; top: 2px; left: 2px;
  transition: left 150ms ease;
  box-shadow: 0 1px 2px rgba(0,0,0,.2);
}
.pid-tweaks__switch.is-on { background: var(--sd-navy-900); }
.pid-tweaks__switch.is-on::after { left: 16px; }

/* status modes (driven by tweak select) */
.pid[data-status="posted"] .pill-age,
.pid[data-status="confirmed"] .pill-age { display: none; }

.pid svg { max-width: 100%; max-height: 100%; }

/* ============================================================================
   FOCUS RINGS — unified teal halo for keyboard users.
   Pattern: 3px ring at 30% alpha, no outline. Apply via :focus-visible.
   ============================================================================ */
.view-chip:focus-visible,
.kpiseg:focus-visible,
.cons__chip:focus-visible,
.cons__icon-btn:focus-visible,
.cons__primary:focus-visible,
.cons__pop-preset:focus-visible,
.cons__pop-btn:focus-visible,
.cons__state-cta:focus-visible,
.cons-tweaks__close:focus-visible,
.cons-tweaks__radio button:focus-visible,
.cons-tweaks__switch:focus-visible,
.bulk__btn:focus-visible,
.bulk__close:focus-visible,
.cons__preview-close:focus-visible,
.preview-btn:focus-visible,
.row-arrow:focus-visible,
.pid__btn:focus-visible,
.pid__listnav-back:focus-visible,
.pid__listnav-btn:focus-visible,
.pid-tweaks__close:focus-visible,
.pid-tweaks__switch:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(23,162,184,.30);
  position: relative;
  z-index: 1;
}

/* sortable column headers — keyboard reachable */
.cons__head .th.is-sortable:focus-visible,
.pid__head .th.is-sortable:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--sd-teal-600);
  color: var(--sd-ink-900);
}

/* checkboxes — visible focus halo over the navy fill */
.row-check:focus-visible,
.head-check:focus-visible,
.cons__pop-opt input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(23,162,184,.30);
}

/* row hover/focus parity — rows are tabbable for whole-row click parity */
.row:focus-visible {
  outline: none;
  background: var(--sd-blue-050);
  box-shadow: inset 0 0 0 2px var(--sd-teal-600);
}

/* inputs already have focus styling via :focus-within on parents,
   but keep an extra direct fallback for plain inputs. */
input:focus-visible:not([type="checkbox"]) {
  outline: none;
}

/* ============================================================================
   DETAIL PAGE STATES (loading skeleton / empty / error).
   Show one based on .pid[data-state="..."]; default keeps the content visible.
   ============================================================================ */
.pid__state { display: none; }
.pid[data-state="loading"] .pid__state--loading { display: block; }
.pid[data-state="empty"]   .pid__state--empty   { display: block; }
.pid[data-state="error"]   .pid__state--error   { display: block; }

/* hide the live content when in non-default state */
.pid[data-state="loading"] .pid__header,
.pid[data-state="loading"] .pid__tiles,
.pid[data-state="loading"] .pid__section-title,
.pid[data-state="loading"] .pid__grid,
.pid[data-state="loading"] .pid__bottom,
.pid[data-state="empty"]   .pid__header,
.pid[data-state="empty"]   .pid__tiles,
.pid[data-state="empty"]   .pid__section-title,
.pid[data-state="empty"]   .pid__grid,
.pid[data-state="empty"]   .pid__bottom,
.pid[data-state="error"]   .pid__header,
.pid[data-state="error"]   .pid__tiles,
.pid[data-state="error"]   .pid__section-title,
.pid[data-state="error"]   .pid__grid,
.pid[data-state="error"]   .pid__bottom { display: none; }

/* Loading skeleton */
.pid__state--loading { padding: 0; }
.pid__skel-header {
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  padding: 22px;
  margin-bottom: 18px;
  display: flex; flex-direction: column; gap: 12px;
}
.pid__skel-tiles {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 22px;
}
.pid__skel-tile {
  padding: 18px 20px;
  border-right: 1px solid var(--sd-line-200);
  display: flex; flex-direction: column; gap: 10px;
}
.pid__skel-tile:last-child { border-right: none; }
.pid__skel-grid {
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  overflow: hidden;
}
.pid__skel-row {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px;
  min-height: 54px;
  border-bottom: 1px solid var(--sd-line-100);
}
.pid__skel-row:last-child { border-bottom: none; }
.skbar {
  height: 11px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--sd-line-100) 0%, var(--sd-line-200) 50%, var(--sd-line-100) 100%);
  background-size: 200% 100%;
  animation: cons-skel 1.4s ease-in-out infinite;
}
.skbar--lg { height: 28px; width: 280px; }
.skbar--md { height: 16px; width: 200px; }
.skbar--sm { height: 11px; }
.skbar--w20 { width: 20%; }
.skbar--w30 { width: 30%; }
.skbar--w40 { width: 40%; }
.skbar--w60 { width: 60%; }
.skbar--w80 { width: 80%; }

/* Empty + error states share a centered art layout */
.pid__state--empty,
.pid__state--error {
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  padding: 80px 32px;
  text-align: center;
}
.pid__state-art { width: 140px; height: 112px; margin: 0 auto 22px; }
.pid__state-title { font-size: 19px; font-weight: 600; color: var(--sd-ink-900); margin-bottom: 8px; letter-spacing: -0.01em; }
.pid__state-body { font-size: 14px; color: var(--sd-ink-500); max-width: 460px; margin: 0 auto 22px; line-height: 1.5; }
.pid__state--error .pid__state-title { color: #8B2A2A; }
.pid__state-detail {
  display: inline-block;
  margin: 0 0 22px;
  padding: 10px 14px;
  background: var(--sd-red-100);
  border: 1px solid #F5C4CC;
  border-radius: 6px;
  font-family: var(--sd-mono);
  font-size: 12px;
  color: #5C1717;
}
.pid__state-actions { display: inline-flex; gap: 8px; align-items: center; }
.pid__state-cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 0 16px;
  height: 38px;
  background: var(--sd-navy-900);
  color: #fff;
  border: none;
  border-radius: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
}
.pid__state-cta:hover { background: #0F1F36; }
.pid__state-cta--ghost {
  background: transparent;
  color: var(--sd-ink-700);
  border: 1px solid var(--sd-line-300);
  text-transform: none;
  letter-spacing: 0;
  font-weight: 500;
  font-size: 13px;
}
.pid__state-cta--ghost:hover { background: var(--sd-line-100); color: var(--sd-ink-900); }

/* ============================================================================
   RESPONSIVE BREAKPOINTS
   The Console direction is a desktop-PWA. Targets:
     - 1440+ px : native (designed)
     - 1280 px  : comfortable (tested)
     - 1024 px  : tolerated — line-item grids horizontal-scroll, tiles wrap to 2x2
     - < 1024 px: NOT supported. We show a banner asking users to widen.
   ============================================================================ */

/* 1280–1440: no changes (default styles). */

/* 1024–1279: grids scroll horizontally, KPI / tile rows go 2x2 */
@media (max-width: 1279px) {
  .cons,
  .pid { padding-left: 20px; padding-right: 20px; }

  /* KPI segments + summary tiles: 4-up → 2x2 */
  .cons__segbar,
  .pid__tiles {
    grid-template-columns: repeat(2, 1fr);
  }
  .cons__segbar .kpiseg:nth-child(2),
  .pid__tiles .pid__tile:nth-child(2) { border-right: none; }
  .cons__segbar .kpiseg:nth-child(1),
  .cons__segbar .kpiseg:nth-child(2),
  .pid__tiles .pid__tile:nth-child(1),
  .pid__tiles .pid__tile:nth-child(2) { border-bottom: 1px solid var(--sd-line-200); }

  /* Long horizontal grids: allow horizontal scroll within the grid card.
     Headers + rows + totals stay locked together because they're inside the
     same scroll container. */
  .cons__grid,
  .pid__grid {
    overflow-x: auto;
  }
  .cons__head,
  .cons__rows,
  .cons__totals,
  .pid__head,
  .pid__rows,
  .pid__totals {
    min-width: 1100px;
  }

  /* Detail bottom: stack 3-card grid into 2 + 1 (or all stacked) */
  .pid__bottom {
    grid-template-columns: 1fr 1fr;
  }
  .pid__bottom > :nth-child(3) { grid-column: span 2; }

  /* Listnav: drop the keyboard hint to save room */
  .pid__listnav-kbd { display: none; }
}

/* 768–1023: full stack */
@media (max-width: 1023px) {
  .cons__segbar,
  .pid__tiles { grid-template-columns: 1fr; }
  .cons__segbar .kpiseg,
  .pid__tiles .pid__tile {
    border-right: none;
    border-bottom: 1px solid var(--sd-line-200);
  }
  .cons__segbar .kpiseg:last-child,
  .pid__tiles .pid__tile:last-child { border-bottom: none; }
  .pid__bottom { grid-template-columns: 1fr; }
  .pid__bottom > :nth-child(3) { grid-column: auto; }

  /* Header actions wrap below the title block */
  .pid__header { flex-direction: column; align-items: stretch; }
  .pid__actions { flex-wrap: wrap; }
}

/* < 768: viewport-too-narrow banner (handled via JS or page-level guard).
   Below this width we show a friendly "open on a wider screen" notice
   instead of trying to cram the operations console. The banner is
   styled here so any page can drop in:
       <div class="console-too-narrow">…</div>
*/
.console-too-narrow {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--sd-bg-app);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.console-too-narrow__inner {
  max-width: 360px;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  padding: 32px 24px;
  box-shadow: var(--sd-shadow-md);
}
.console-too-narrow__title {
  font-size: 16px;
  font-weight: 600;
  color: var(--sd-ink-900);
  margin-bottom: 8px;
}
.console-too-narrow__body {
  font-size: 13px;
  color: var(--sd-ink-500);
  line-height: 1.5;
}
@media (max-width: 767px) {
  .console-too-narrow { display: flex; }
  body { overflow: hidden; }
}

/* ============================================================================
   PARTIES BLOCK (supplier → ship-to) — sits between title and summary tiles.
   ============================================================================ */
.pid__parties {
  display: grid;
  grid-template-columns: 1fr 32px 1fr;
  gap: 0;
  background: #fff;
  border: 1px solid var(--sd-line-300);
  border-radius: 12px;
  margin-bottom: 22px;
  overflow: hidden;
}
.pid__party {
  padding: 14px 20px 16px;
  min-width: 0;
}
.pid__party + .pid__parties-arrow + .pid__party {
  border-left: 1px solid var(--sd-line-200);
}
.pid__parties-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--sd-ink-300);
  background: var(--sd-bg-soft);
}
.pid__parties-arrow svg { width: 16px; height: 16px; }
.pid__party-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
  margin-bottom: 8px;
  white-space: nowrap;
}
.pid__party-label .badge {
  font-family: var(--sd-mono);
  font-size: 10.5px;
  font-weight: 500;
  color: var(--sd-ink-500);
  letter-spacing: 0;
  text-transform: none;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--sd-bg-soft);
  border: 1px solid var(--sd-line-200);
}
.pid__party-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--sd-ink-900);
  letter-spacing: -0.005em;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pid__party-row {
  display: flex;
  gap: 8px;
  align-items: baseline;
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--sd-ink-700);
  margin-bottom: 3px;
}
.pid__party-row .key {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
  flex: 0 0 56px;
}
.pid__party-row .val {
  flex: 1;
  min-width: 0;
}
.pid__party-row .val.mono {
  font-family: var(--sd-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--sd-ink-800);
}
.pid__party-row .state-chip {
  display: inline-flex;
  align-items: center;
  font-family: var(--sd-mono);
  font-size: 10.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--sd-bg-soft);
  color: var(--sd-ink-500);
  border: 1px solid var(--sd-line-200);
  margin-left: 6px;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

/* Stack vertically on narrow viewports */
@media (max-width: 1023px) {
  .pid__parties { grid-template-columns: 1fr; }
  .pid__parties-arrow { display: none; }
  .pid__party + .pid__party { border-left: none; border-top: 1px solid var(--sd-line-200); }
}

/* ============================================================================
   Option A header: invoice-as-title
   - Small caps "Invoice" eyebrow
   - Mono invoice ID as the big title
   - Subtitle: supplier → customer
   - Meta line with status pill leading
   ============================================================================ */
.pid__eyebrow-kicker {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
}
.pid__title--mono {
  font-family: var(--sd-mono);
  font-size: 26px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.pid__subtitle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 15px;
  font-weight: 500;
  color: var(--sd-ink-800);
  margin: 6px 0 12px;
  flex-wrap: wrap;
}
.pid__subtitle-arrow {
  width: 14px; height: 14px;
  color: var(--sd-ink-300);
  flex-shrink: 0;
}
.pid__meta a {
  color: var(--sd-blue-600);
  text-decoration: none;
  font-family: var(--sd-mono);
  font-size: 12.5px;
  white-space: nowrap;
}
.pid__meta a:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ============================================================================
   Invoice breakdown — grouped sections with subtle separators
   ============================================================================ */
.pid__breakdown-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--sd-line-200);
}
.pid__breakdown-group:first-child { padding-top: 0; }
.pid__breakdown-group-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
  margin-bottom: 3px;
}
.pid__breakdown-row--muted .lbl,
.pid__breakdown-row--muted .val {
  color: var(--sd-ink-500);
  font-size: 12.5px;
}
.pid__breakdown-row--variance .lbl { color: var(--sd-ink-500); font-size: 12.5px; }
.pid__breakdown-row--variance .val {
  color: var(--sd-amber-text);
  font-weight: 600;
}
.pid__breakdown-foot {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--sd-bg-soft);
  border-radius: 6px;
  font-size: 12.5px;
}
.pid__breakdown-foot-key {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
}
.pid__breakdown-foot-val { color: var(--sd-ink-800); }
.pid__breakdown-foot-val strong { color: var(--sd-ink-900); font-weight: 600; }

/* ============================================================================
   Compliance & logistics card — sectioned dl
   ============================================================================ */
.pid__compl { display: flex; flex-direction: column; gap: 14px; }
.pid__compl-section {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--sd-line-200);
}
.pid__compl-section:last-child { border-bottom: none; padding-bottom: 0; }
.pid__compl-section-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--sd-ink-400);
  margin-bottom: 6px;
}
