/* NGIPL Price List Manager, app chrome, tables, print sheet */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-body);
  background: var(--surface-paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--ngipl-black); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--gray-700); }
input, select, textarea, button { font-family: var(--font-body); }

.overline {
  font-size: var(--fs-overline);
  font-weight: var(--fw-semibold);
  text-transform: uppercase;
  letter-spacing: var(--track-caps);
}
.caption { font-size: var(--fs-caption); color: var(--text-muted); line-height: var(--lh-caption); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- App chrome ---------- */
.app-top {
  background: var(--surface-page);
  border-bottom: var(--bw-hairline) solid var(--border-strong);
}
.app-top-inner {
  max-width: 1280px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; gap: 20px;
}
.app-logo { height: 40px; display: block; }
.app-wordmark { line-height: 1; }
.app-wordmark .wm-name { font-size: 15px; font-weight: var(--fw-display); letter-spacing: 0.03em; color: var(--ngipl-black); }
.app-wordmark .wm-sub { font-size: 7px; font-weight: var(--fw-semibold); letter-spacing: 0.29em; margin-top: 3px; color: var(--gray-700); }
.app-top-divider { width: 1px; height: 28px; background: var(--border-default); }
.app-title { font-size: 11px; letter-spacing: var(--track-overline); color: var(--text-muted); font-weight: var(--fw-semibold); text-transform: uppercase; }
.app-top-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

.app-tabs-band { background: var(--surface-page); border-bottom: var(--bw-hairline) solid var(--border-default); }
.app-tabs { max-width: 1280px; margin: 0 auto; padding: 0 24px; display: flex; gap: 28px; }
.app-tab {
  appearance: none; background: none; border: none; cursor: pointer;
  padding: 14px 2px 12px; margin-bottom: -1px;
  font-size: var(--fs-overline); font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: var(--track-caps);
  color: var(--text-muted); border-bottom: var(--bw-strong) solid transparent;
  transition: color var(--dur-fast) var(--ease-brand), border-color var(--dur-fast) var(--ease-brand);
}
.app-tab:hover { color: var(--text-display); }
.app-tab--active { color: var(--text-display); border-bottom-color: var(--ngipl-black); }
.app-tab .tab-badge { margin-left: 6px; }

.app-main { max-width: 1280px; margin: 0 auto; padding: 24px 24px 80px; }

/* ---------- Cards / panels ---------- */
.panel { background: var(--surface-card); border: var(--bw-hairline) solid var(--border-default); }
.panel--strong { border-color: var(--border-strong); }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

/* ---------- Data table ---------- */
.plm-table-wrap { overflow: auto; }
.plm-table { width: 100%; border-collapse: collapse; background: var(--surface-card); }
.plm-table th {
  text-align: left; font-size: 10.5px; font-weight: var(--fw-semibold);
  text-transform: uppercase; letter-spacing: var(--track-caps);
  color: var(--text-muted); padding: 10px 12px;
  border-bottom: var(--bw-strong) solid var(--ngipl-black);
  background: var(--surface-card); position: sticky; top: 0; z-index: 2;
  white-space: nowrap;
}
.plm-table td {
  padding: 8px 12px; border-bottom: var(--bw-hairline) solid var(--border-subtle);
  font-size: 13.5px; vertical-align: middle;
}
.density-compact .plm-table td { padding: 4px 12px; font-size: 12.5px; }
.plm-table tr.cat-band td {
  background: var(--surface-dark); color: var(--ngipl-white);
  font-size: 11px; font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--track-overline); padding: 6px 12px; border-bottom: none;
}
.band-cell { display: inline-flex; align-items: center; gap: 10px; }
.band-cell svg { display: block; }
.plm-table tr.sub-band td {
  background: var(--surface-sunken); color: var(--gray-700);
  font-size: 10px; font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--track-caps); padding: 5px 12px;
  border-bottom: var(--bw-hairline) solid var(--border-subtle);
}
.plm-table tbody tr.item-row:hover td { background: var(--surface-sunken); }
.plm-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.plm-table .rate { font-weight: var(--fw-semibold); }
.plm-table .col-no { color: var(--text-faint); width: 44px; font-variant-numeric: tabular-nums; }
.item-note { font-size: 11.5px; color: var(--text-faint); margin-top: 1px; }
.row-actions { opacity: 1; transition: opacity var(--dur-fast) var(--ease-brand); white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
  .row-actions { opacity: 0; }
  tr:hover .row-actions { opacity: 1; }
}

/* drag to reorder (master list) */
.item-name-line { display: flex; align-items: flex-start; gap: 6px; }
.drag-grip {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 20px; margin-left: -4px; color: var(--gray-400);
  cursor: grab; touch-action: none; -webkit-user-select: none; user-select: none;
}
.master-rows tr.item-row { cursor: grab; }
.master-rows tr.item-row:hover .drag-grip { color: var(--gray-700); }
.master-rows tr.item-row.is-dragging td { opacity: 0.35; }
.master-rows tr.item-row.drop-before td { box-shadow: inset 0 2px 0 var(--ngipl-black); }
.master-rows tr.item-row.drop-after td { box-shadow: inset 0 -2px 0 var(--ngipl-black); }
body.is-reordering, body.is-reordering * { cursor: grabbing !important; -webkit-user-select: none !important; user-select: none !important; }
.drag-ghost {
  position: fixed; z-index: 90; pointer-events: none; max-width: 280px;
  background: var(--ngipl-black); color: #ffffff; font-size: 12px; padding: 6px 10px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* rate inline edit */
.rate-view { cursor: pointer; border-bottom: 1px dashed var(--gray-400); padding-bottom: 1px; }
.rate-view:hover { border-bottom-color: var(--ngipl-black); color: var(--ngipl-black); }
.rate-input {
  width: 76px; padding: 3px 6px; font-size: 13px; text-align: right;
  border: var(--bw-hairline) solid var(--ngipl-black); border-radius: var(--radius-1);
  font-variant-numeric: tabular-nums; outline: none; font-weight: var(--fw-semibold);
}

/* chips / tags */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  border: var(--bw-hairline) solid var(--border-default);
  padding: 2px 8px; font-size: 10.5px; font-weight: var(--fw-semibold);
  letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gray-700);
  background: var(--surface-card); white-space: nowrap;
}
.chip--click { cursor: pointer; }
.chip--click:hover { border-color: var(--ngipl-black); color: var(--ngipl-black); }
.chip--dark { background: var(--ngipl-black); color: var(--ngipl-white); border-color: var(--ngipl-black); }
.chip--warn { border-color: var(--amber-700); color: var(--amber-700); background: var(--amber-50); }
.chip--ghost { border-color: transparent; color: var(--text-faint); }

/* filter chips row */
.filter-chips { display: flex; gap: 8px; align-items: center; }
.fchip {
  appearance: none; cursor: pointer; background: var(--surface-card);
  border: var(--bw-hairline) solid var(--border-default);
  padding: 5px 12px; font-size: 10.5px; font-weight: var(--fw-semibold);
  letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gray-700);
  transition: all var(--dur-fast) var(--ease-brand);
}
.fchip:hover { border-color: var(--ngipl-black); color: var(--ngipl-black); }
.fchip--on { background: var(--ngipl-black); color: var(--ngipl-white); border-color: var(--ngipl-black); }

/* ---------- Parties layout ---------- */
.parties-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.plm-table .num, .plm-table td:last-child { white-space: nowrap; }
.plm-table-wrap { overflow: auto; }
.party-card {
  display: block; width: 100%; text-align: left; cursor: pointer;
  background: var(--surface-card); border: var(--bw-hairline) solid var(--border-default);
  border-bottom: none; padding: 12px 14px; appearance: none;
  transition: background var(--dur-fast) var(--ease-brand);
}
.party-card:last-child { border-bottom: var(--bw-hairline) solid var(--border-default); }
.party-card:hover { background: var(--surface-sunken); }
.party-card--on { background: var(--ngipl-black); }
.party-card--on:hover { background: var(--ngipl-black); }
.party-card--on .pc-name { color: var(--ngipl-white); }
.party-card--on .pc-meta { color: var(--text-inverse-muted); }
.pc-name { font-weight: var(--fw-semibold); font-size: 13.5px; color: var(--text-display); display: flex; align-items: center; gap: 8px; }
.pc-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }

/* ---------- Special price list ----------
   The price list is first in the markup so it comes first on a phone; on a desktop
   the grid puts the customers panel in the left column. */
.sp-customers { grid-column: 1; grid-row: 1; }
.sp-main { grid-column: 2; grid-row: 1; min-width: 0; }
.sp-cust-head { display: flex; align-items: baseline; gap: 8px; padding: 14px 14px 2px; }
.sp-cust-count { margin-left: auto; }
.sp-cust-toggle { display: none; }
.sp-cust-title { font-size: 13px; font-weight: var(--fw-semibold); color: var(--text-display); }
.sp-cust-note { padding: 0 14px 10px; }
.sp-cust-add { display: flex; gap: 8px; align-items: center; padding: 0 14px 6px; }
.sp-cust-add .f-input { flex: 1; min-width: 0; }
.sp-cust-msg { padding: 0 14px 6px; }
.sp-cust-list { max-height: 360px; overflow-y: auto; border-top: var(--bw-hairline) solid var(--border-subtle); }
.sp-cust-row { display: flex; align-items: center; gap: 4px; padding: 4px 6px 4px 14px; border-bottom: var(--bw-hairline) solid var(--border-subtle); }
.sp-cust-row:last-child { border-bottom: none; }
.sp-cust-name { flex: 1; min-width: 0; font-size: 13px; overflow-wrap: anywhere; }
.sp-cust-edit { flex: 1; min-width: 0; height: 32px; }
.sp-cust-acts { display: inline-flex; flex: none; }
.sp-cust-acts .ngipl-iconbtn[disabled] { opacity: 0.4; cursor: not-allowed; }
.sp-cust-empty { padding: 4px 14px 16px; }
/* customer routes (v52): name above, route and Add below; chips; one heading per route */
.sp-cust-add { flex-direction: column; align-items: stretch; }
.sp-cust-add .f-input { flex: none; }
.sp-cust-add2 { display: flex; gap: 8px; align-items: center; }
.sp-route-select { flex: 1; min-width: 0; }
.sp-cust-warn { padding: 0 14px 8px; color: var(--amber-700); }
.sp-route-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 10px; }
.sp-route-chips .fchip { padding: 5px 9px; }
.sp-cust-group { display: flex; align-items: baseline; gap: 6px; padding: 8px 14px 6px; background: var(--gray-50, #f6f5f5); border-bottom: var(--bw-hairline) solid var(--border-subtle); font-size: 12px; font-weight: var(--fw-semibold); color: var(--text-display); }
.sp-cust-group-name { flex: none; }
.sp-cust-group-hint { flex: 1; min-width: 0; font-size: 11px; font-weight: 400; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sp-cust-group-count { flex: none; margin-left: auto; color: var(--text-muted); }
.sp-cust-group--warn { background: var(--amber-50); color: var(--amber-700); }
.sp-cust-group--warn .sp-cust-group-count { color: var(--amber-700); }
.sp-cust-main { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.sp-cust-main .sp-cust-name { flex: none; max-width: 100%; }
.sp-setroute { border-color: var(--amber-700); color: var(--amber-700); background: var(--amber-50); margin-bottom: 2px; }
.sp-cust-row--edit { flex-direction: column; align-items: stretch; gap: 8px; padding: 8px 14px 10px; }
.sp-cust-row--edit .sp-cust-msg { padding: 0; }
.sp-cust-row--edit .sp-cust-edit, .sp-cust-row--edit .sp-route-select { flex: none; } /* stacked here, so "flex: 1" would squash them to one text line */
.sp-cust-edit-btns { display: flex; gap: 8px; }
.sp-print-list .sp-print-group { border-bottom: none; border-radius: 4px; }
.sp-stats { margin-bottom: 16px; }
.sp-stats .stat-strip { border-bottom: none; }
.sp-stat-warn { color: var(--amber-700); }
.sp-banner-icon { flex: none; }
.sp-banner-text { flex: 1 1 auto; min-width: 0; }
.sp-rows { max-height: calc(100vh - 380px); min-height: 240px; }
/* The to-review chip with Keep and Match sits under the item name at every width. In the
   last column it made that column 305px wide and left the item name 131px. */
.sp-review { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; }
.sp-item-line { display: flex; align-items: center; gap: 8px; }
.sp-row-stale td { background: var(--amber-50); }
.sp-th-rate { width: 96px; }
.sp-th-master { width: 90px; }
.sp-th-diff { width: 70px; }
.sp-th-gst { width: 60px; }
.sp-th-pack { width: 84px; }
.sp-th-outer { width: 90px; }
.sp-th-act { width: 56px; }
.sp-faint { color: var(--text-faint); }
.sp-diff-up { color: var(--green-600, #1f8a5b); font-weight: 600; }
.sp-diff-down { color: var(--red-600, #a83232); font-weight: 600; }
.sp-empty { padding: 40px; text-align: center; }
.sp-chip-sm { font-size: 9px; }
.sp-search-box { flex: 0 1 280px; }
.sp-add-list { max-height: 320px; overflow: auto; }
.sp-add-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.sp-foot-note { margin-right: auto; }
.sp-preview { max-height: 260px; overflow: auto; }
.sp-prev-arrow { width: 30px; color: var(--text-faint); }
.sp-prev-old { width: 90px; color: var(--text-faint); }
.sp-prev-new { width: 110px; }
.sp-prev-flag { margin-top: 3px; }
.sp-hint { margin-top: 4px; }
.sp-print-list { display: flex; flex-direction: column; gap: 8px; }
/* Two classes on purpose: the button styles are injected after this stylesheet, so a
   single class would lose the tie and the names would come out in capitals, centred. */
.sp-print-list .sp-print-btn { width: 100%; height: auto; min-height: 36px; padding: 8px 14px; justify-content: flex-start; text-align: left; white-space: normal; text-transform: none; letter-spacing: 0; font-size: 13px; font-weight: var(--fw-medium, 500); }
/* Between a phone and a wide desktop (a tablet held upright is 768px) the two columns
   would leave the price table 393px, less than its columns need, so the customers go
   on top and the table takes the full width. The word screen keeps this off paper. */
@media screen and (max-width: 1000px) {
  .parties-grid { grid-template-columns: minmax(0, 1fr); }
  .sp-customers, .sp-main { grid-column: 1; grid-row: auto; }
  .sp-customers { order: -1; }
  /* Five or six full tab labels do not fit on one line here (at 768px they wrapped to two),
     so from five tabs up this range uses the short labels the phone layout already has. */
  .app-tabs:has(.app-tab:nth-child(5)) .tab-full { display: none; }
  .app-tabs:has(.app-tab:nth-child(5)) .tab-short { display: inline; }
}

.stat-strip { display: flex; border-bottom: var(--bw-hairline) solid var(--border-default); }
.stat-cell { padding: 12px 20px 12px 16px; border-right: var(--bw-hairline) solid var(--border-subtle); }
.stat-cell:last-child { border-right: none; }
.stat-num { font-size: 22px; font-weight: var(--fw-display); letter-spacing: var(--track-display); line-height: 1.1; }
.stat-lbl { font-size: 9.5px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--text-muted); margin-top: 2px; }

/* stale review banner */
.review-banner {
  display: flex; align-items: center; gap: 10px;
  border: var(--bw-hairline) solid var(--amber-700); background: var(--amber-50);
  padding: 8px 14px; margin-bottom: 14px; font-size: 12.5px; color: var(--amber-700);
}

/* ---------- Dialogs ---------- */
.dlg-scrim {
  position: fixed; inset: 0; background: var(--surface-scrim); z-index: 50;
  display: flex; align-items: flex-start; justify-content: center; padding: 60px 20px 40px;
  overflow: auto;
}
.dlg {
  background: var(--surface-card); border: var(--bw-hairline) solid var(--ngipl-black);
  width: 560px; max-width: 100%;
  box-shadow: var(--shadow-overlay, 0 12px 40px rgba(34,32,33,0.24));
}
.dlg-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: var(--bw-hairline) solid var(--border-default);
}
.dlg-title { font-size: 13px; font-weight: var(--fw-display); text-transform: uppercase; letter-spacing: var(--track-caps); }
.dlg-body { padding: 20px; }
.dlg-foot {
  display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px;
  border-top: var(--bw-hairline) solid var(--border-default); background: var(--surface-sunken);
}

/* ---------- Drawer ---------- */
.drawer-scrim { position: fixed; inset: 0; background: var(--surface-scrim); z-index: 50; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 440px; max-width: 92vw;
  background: var(--surface-card); border-left: var(--bw-hairline) solid var(--ngipl-black);
  z-index: 51; display: flex; flex-direction: column;
  animation: drawer-in var(--dur-base) var(--ease-brand);
}
@keyframes drawer-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.drawer-body { flex: 1; overflow: auto; }
.hist-item { padding: 12px 20px; border-bottom: var(--bw-hairline) solid var(--border-subtle); }
.hist-label { font-size: 13px; }
.hist-meta { font-size: 11px; color: var(--text-faint); margin-top: 3px; letter-spacing: 0.04em; }
.hist-changes { margin: 8px 0 0; padding: 8px 12px; background: var(--surface-sunken); font-size: 12px; }
.hist-changes div { padding: 2px 0; display: flex; justify-content: space-between; gap: 12px; }

/* ---------- Forms ---------- */
.f-label { display: block; font-size: 10.5px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gray-700); margin-bottom: 5px; }
.f-input, .f-select, .f-textarea {
  width: 100%; height: 38px; padding: 0 12px; font-size: 13.5px; color: var(--text-body);
  border: var(--bw-hairline) solid var(--gray-400); border-radius: var(--radius-1);
  background: var(--surface-card); outline: none;
  transition: border-color var(--dur-fast) var(--ease-brand);
}
.f-textarea { height: auto; padding: 9px 12px; resize: vertical; line-height: 1.5; }
.f-input:hover, .f-select:hover, .f-textarea:hover { border-color: var(--gray-600); }
.f-input:focus, .f-select:focus, .f-textarea:focus { border-color: var(--ngipl-black); }
.f-row { display: flex; gap: 14px; }
.f-row > * { flex: 1; min-width: 0; }
.f-stack { display: flex; flex-direction: column; gap: 14px; }
.f-select { appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' fill='none' stroke='%23222021' stroke-width='1.5'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ---------- W.E.F. calendar ---------- */
.wef-field { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; text-align: left; background: var(--surface-card); font-family: inherit; }
.cal-pop {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 60;
  background: var(--surface-card); border: var(--bw-hairline) solid var(--ngipl-black);
  padding: 12px; width: 252px; box-sizing: border-box;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.14);
}
.cal-pop--right { left: auto; right: 0; }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-title { font-size: 11.5px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--text-display); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow { font-size: 9px; font-weight: var(--fw-semibold); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-faint); text-align: center; padding: 4px 0 6px; }
.cal-day {
  appearance: none; background: none; font-family: inherit; cursor: pointer;
  height: 28px; font-size: 12px; color: var(--text-body);
  border: var(--bw-hairline) solid transparent; border-radius: var(--radius-0);
  transition: background-color var(--dur-fast) var(--ease-brand), border-color var(--dur-fast) var(--ease-brand);
}
.cal-day:hover { background: var(--surface-sunken); }
.cal-day--today { border-color: var(--gray-500); }
.cal-day--sel { background: var(--ngipl-black); color: var(--ngipl-white); border-color: var(--ngipl-black); }
.cal-day--sel:hover { background: var(--gray-800); }
.cal-foot { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; padding-top: 9px; border-top: var(--bw-hairline) solid var(--border-default); }
.cal-today { appearance: none; background: none; border: none; padding: 0; font-family: inherit; font-size: 11.5px; font-weight: var(--fw-semibold); color: var(--text-display); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.cal-today:hover { color: var(--gray-700); }

.search-box { position: relative; }
.search-box .f-input { padding-left: 34px; width: 280px; }
.search-box svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-faint); }

/* segmented */
.seg { display: inline-flex; border: var(--bw-hairline) solid var(--gray-400); border-radius: var(--radius-1); overflow: hidden; }
.seg button {
  appearance: none; border: none; background: var(--surface-card); cursor: pointer;
  padding: 7px 14px; font-size: 10.5px; font-weight: var(--fw-semibold);
  letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gray-700);
  border-right: var(--bw-hairline) solid var(--gray-300);
}
.seg button:last-child { border-right: none; }
.seg button.on { background: var(--ngipl-black); color: var(--ngipl-white); }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ngipl-black); color: var(--ngipl-white); padding: 10px 18px;
  font-size: 12.5px; max-width: 560px; text-align: center;
  animation: toast-in var(--dur-base) var(--ease-brand);
}
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Print sheet ---------- */
.print-grid { display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start; }
.print-opts { display: flex; gap: 16px; align-items: flex-end; padding: 12px 16px; margin-bottom: 16px; }
.print-desk {
  background: var(--surface-dark);
  border: var(--bw-hairline) solid var(--ngipl-black);
  padding: 26px 28px 40px; overflow: auto;
}
.desk-doclabel {
  color: var(--text-inverse-muted); font-size: 10px; font-weight: var(--fw-semibold);
  letter-spacing: var(--track-overline); text-transform: uppercase;
  text-align: center; margin-bottom: 18px;
}
.sheet-scale { width: 794px; margin: 0 auto; transform-origin: top left; }
.print-desk .sheet { border: none; }
.sheet-canvas { overflow: auto; padding: 4px; }
.sheet {
  width: 794px; min-height: 1123px; margin: 0 auto; background: #ffffff;
  border: var(--bw-hairline) solid var(--border-default);
  color: var(--ngipl-black);
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet-pad { padding: 36px 40px 32px; }

.sheet-band { position: relative; background: var(--ngipl-charcoal); color: var(--ngipl-white); padding: 20px 32px; display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.sheet-band .band-fill { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; display: block; }
.sheet-band img, .sheet-band .co-block { position: relative; z-index: 1; }
.sheet-band img { height: 118px; display: block; }
.sheet-band .co-block { text-align: right; font-size: 8.5px; line-height: 1.7; color: rgba(255,255,255,0.72); letter-spacing: 0.02em; }
.sheet-band .co-name { font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--ngipl-white); margin-bottom: 3px; }

.sheet-min-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; padding: 20px 32px; }
.sheet-min-head img { height: 118px; display: block; }
.sheet-min-head .co-block { text-align: right; font-size: 8.5px; line-height: 1.7; color: var(--gray-600); }
.sheet-min-head .co-name { font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--ngipl-black); margin-bottom: 3px; }
.sheet-rule { border-top: var(--bw-strong) solid var(--ngipl-black); margin: 0 32px; }

/* category icons, named row below the co-details, right-justified with them */
.sheet-icons { display: flex; justify-content: flex-end; align-items: flex-start; gap: 22px; margin-top: 10px; }
.sheet-icon { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; }
.sheet-icon-name { font-size: 6.5px; font-weight: var(--fw-semibold); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }
.sheet-band .sheet-icons { color: var(--ngipl-white); }
.sheet-min-head .sheet-icons { color: var(--ngipl-black); }

.sheet-titlerow { display: flex; align-items: center; justify-content: space-between; padding: 14px 32px; }
.sheet-title { font-size: 26px; font-weight: var(--fw-display); letter-spacing: var(--track-display); text-transform: uppercase; line-height: 1; }
.sheet-wef { font-size: 10px; font-weight: var(--fw-semibold); letter-spacing: var(--track-overline); text-transform: uppercase; }
.sheet-wef--big { font-size: 26px; font-weight: var(--fw-display); letter-spacing: var(--track-display); line-height: 1; }
.sheet-subrow { padding: 0 32px 10px; display: flex; justify-content: space-between; align-items: baseline; }
.sheet-for { font-size: 11px; letter-spacing: var(--track-caps); text-transform: uppercase; font-weight: var(--fw-semibold); color: var(--gray-700); }

.sheet table { width: 100%; border-collapse: collapse; }
.sheet .pt { margin: 0 32px 0; }
.sheet th {
  text-align: left; font-size: 8px; font-weight: var(--fw-semibold); text-transform: uppercase;
  letter-spacing: var(--track-caps); color: var(--gray-600);
  border-top: var(--bw-hairline) solid var(--ngipl-black);
  border-bottom: var(--bw-hairline) solid var(--ngipl-black);
  padding: 5px 6px;
}
.sheet td { font-size: 10.5px; padding: 3px 6px; border-bottom: 0.5px solid var(--gray-300); vertical-align: top; }
.sheet tr.s-cat td {
  background: var(--ngipl-black); color: var(--ngipl-white);
  font-size: 9px; font-weight: var(--fw-semibold); letter-spacing: var(--track-overline);
  text-transform: uppercase; padding: 4px 6px; border-bottom: none;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet tr.s-cat td .cat-cell { display: flex; align-items: center; gap: 9px; }
.sheet tr.s-cat svg { display: block; }
.sheet tr.s-sub td {
  font-size: 8px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps);
  text-transform: uppercase; color: var(--gray-600); background: var(--gray-50);
  padding: 3px 6px; -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.sheet .num { text-align: right; font-variant-numeric: tabular-nums; }
.sheet .s-rate { font-weight: var(--fw-semibold); }
.sheet .s-no { color: var(--gray-500); }
.sheet .s-note { font-size: 8.5px; color: var(--gray-500); }
td .s-note { display: inline; margin-left: 6px; }
.sheet-foot { margin: 12px 32px 0; border-top: var(--bw-hairline) solid var(--ngipl-black); padding-top: 8px; display: flex; justify-content: space-between; gap: 20px; }
.sheet-foot .fnote { font-size: 8.5px; color: var(--gray-600); line-height: 1.6; max-width: 420px; }
.sheet-foot .fmark { font-size: 9px; font-weight: var(--fw-semibold); letter-spacing: var(--track-overline); text-transform: uppercase; white-space: nowrap; }

/* ---------- Visual catalogue ---------- */
.vc-controls { display: flex; align-items: flex-start; gap: 28px; flex-wrap: wrap; row-gap: 14px; }
.vc-ctl { display: flex; flex-direction: column; gap: 6px; }
.vc-ctl .caption { max-width: 220px; line-height: 1.5; }
.vc-ctl--actions { align-items: flex-end; }
.vc-desk { background: var(--surface-sunken); border: var(--bw-hairline) solid var(--border-default); padding: 24px; display: flex; justify-content: flex-start; overflow: auto; }
.vc-sheet { background: #ffffff; border: var(--bw-hairline) solid var(--border-default); flex: none; }
.vc-sheet--a4 { width: 794px; }
.vc-sheet--mobile { width: 430px; }
.vc-cover { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 46px 32px 30px; }
.vc-cover img { height: 120px; }
.vc-cover-rule { width: 56px; border-top: 2px solid var(--ngipl-black); margin: 18px 0 14px; }
.vc-cover-title { font-size: 13px; font-weight: var(--fw-semibold); letter-spacing: var(--track-overline); text-transform: uppercase; }
.vc-cover-wef { font-size: 9.5px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; color: var(--gray-600); margin-top: 8px; }
.vc-band { display: flex; align-items: center; gap: 10px; background: var(--ngipl-charcoal); color: var(--ngipl-white); padding: 9px 18px; margin: 0 18px 12px; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.vc-band-nm { font-size: 11px; font-weight: var(--fw-semibold); letter-spacing: var(--track-caps); text-transform: uppercase; }
.vc-band-ct { margin-left: auto; font-size: 9px; font-weight: var(--fw-semibold); letter-spacing: var(--track-overline); text-transform: uppercase; color: rgba(255,255,255,0.6); }
.vc-cat { padding-bottom: 8px; }
.vc-grid { display: grid; gap: 12px; padding: 0 18px 10px; }
.vc-sheet--a4 .vc-grid--grid { grid-template-columns: repeat(3, 1fr); }
.vc-sheet--a4 .vc-grid--showcase { grid-template-columns: repeat(2, 1fr); }
.vc-sheet--a4 .vc-grid--compact { grid-template-columns: repeat(4, 1fr); gap: 8px; }
.vc-sheet--mobile .vc-grid--grid { grid-template-columns: repeat(2, 1fr); }
.vc-sheet--mobile .vc-grid--showcase { grid-template-columns: 1fr; }
.vc-sheet--mobile .vc-grid--compact { grid-template-columns: repeat(3, 1fr); gap: 8px; }
.vc-card { border: var(--bw-hairline) solid var(--border-default); display: flex; flex-direction: column; break-inside: avoid; }
.vc-ph { background: #ffffff; display: flex; align-items: center; justify-content: center; height: 132px; padding: 10px; border-bottom: var(--bw-hairline) solid var(--border-default); }
.vc-card--showcase .vc-ph { height: 210px; }
.vc-card--compact .vc-ph { height: 92px; padding: 6px; }
.vc-ph img { max-width: 100%; max-height: 100%; object-fit: contain; }
.vc-ph--empty { background: var(--surface-page); color: var(--gray-400); }
.vc-ph-fallback { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.vc-ph-soon { font-size: 7px; font-weight: var(--fw-semibold); letter-spacing: 0.18em; text-transform: uppercase; color: var(--gray-500); white-space: nowrap; }
.vc-card--compact .vc-ph-soon { font-size: 6px; letter-spacing: 0.12em; }
.vc-bd { padding: 8px 10px 9px; display: flex; flex-direction: column; gap: 3px; }
.vc-card--compact .vc-bd { padding: 6px 8px 7px; }
.vc-nm { font-size: 10.5px; font-weight: var(--fw-semibold); line-height: 1.35; }
.vc-card--showcase .vc-nm { font-size: 12px; }
.vc-card--compact .vc-nm { font-size: 9px; }
.vc-note { font-size: 8px; color: var(--gray-500); line-height: 1.4; }
.vc-meta { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; }
.vc-rate { font-size: 11px; font-weight: var(--fw-bold, 700); }
.vc-card--compact .vc-rate { font-size: 9.5px; }
.vc-unit { font-size: 8px; color: var(--gray-500); text-transform: uppercase; letter-spacing: 0.06em; }
.vc-foot { display: flex; justify-content: space-between; gap: 20px; border-top: var(--bw-hairline) solid var(--ngipl-black); margin: 8px 18px 0; padding: 10px 0 16px; font-size: 8.5px; color: var(--gray-600); }

/* ---------- Classes the narrow block below switches on ---------- */
.row-meta { display: none; font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.f-input--sm { height: 34px; font-size: 12.5px; }
.tab-short { display: none; }
.master-rows { max-height: calc(100vh - 220px); max-height: calc(100dvh - 220px); }
.qq-rows { max-height: 38vh; }
#plm-cloud-chip { left: 14px; bottom: 14px; }

/* Verbatim transcriptions of inline styles moved out of the JSX so the narrow
   block below can reach them. Desktop must not move by one pixel. */
.toolbar--tight { margin-bottom: 12px; }
.f-input--client { width: 280px; max-width: 100%; }
.po-field--note { flex: 1; }
.po-count { align-self: center; }
/* .print-opts prefix on purpose: PLM_BTN_CSS is injected after this stylesheet,
   so a 0,1,0 rule would lose the tie and turn the button black. */
.print-opts .po-clear { align-self: center; color: var(--red-700); }
.po-confirm { align-self: center; display: inline-flex; align-items: center; gap: 8px; }
.vc-check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; height: 32px; }
.vc-actions { display: flex; gap: 10px; }

/* ---------- Narrow screens (phones).
   Scoped to `screen` on purpose: in paged media the viewport is the page box, and
   A4 at this file's margins is about 726px, so an unscoped max-width:760px block
   would also apply on paper. Inline styles in the JSX outrank everything here, so
   sizes must live in CSS, not inline. 760px keeps iPad portrait (768) on the
   desktop layout, where the sheet still fits. ---------- */
@media screen and (max-width: 760px) {
  /* app chrome: stop the header pushing History and Settings off-screen */
  .app-top-inner { flex-wrap: wrap; padding: 10px 14px; gap: 10px; }
  .app-wordmark, .app-top-divider, .app-title, .app-top-right .caption { display: none; }
  .app-tabs { gap: 16px; padding: 0 14px 1px; margin-bottom: -1px; overflow-x: auto; scrollbar-width: none; }
  .app-tabs::-webkit-scrollbar { display: none; }
  .app-tab { flex: none; white-space: nowrap; }
  /* five tabs once Admin shows; at 390px the 16px gaps pushed Admin off the edge */
  .app-tabs:has(.app-tab:nth-child(5)) { gap: 12px; }
  .app-tabs:has(.app-tab:nth-child(5)) .app-tab { letter-spacing: 0.06em; }
  /* six tabs for an admin: Master, Special, Quote, Catalogue, Print, Admin */
  .app-tabs:has(.app-tab:nth-child(6)) { gap: 8px; padding: 0 10px 1px; }
  .app-tabs:has(.app-tab:nth-child(6)) .app-tab { letter-spacing: 0.03em; font-size: 10.5px; }
  /* (A staff login now has five tabs. On a 360px phone the five-tab rule above leaves
     Print 9px off the edge; the tighter rule that follows this block brings it in.) */
  .tab-full { display: none; }
  .tab-short { display: inline; }
  .app-main { padding: 14px 14px 80px; }

  /* toolbars: the flex spacer otherwise eats a whole row */
  .toolbar { gap: 8px; }
  .toolbar .spacer { display: none; }
  .search-box { flex: 1 1 100%; }
  .search-box .f-input { width: 100%; }
  /* ---------- The stacked form ----------
     Both control panels become a grid on a phone. This matters beyond tidiness:
     flex properties do not apply to grid items and align-self is a no-op in a
     single-column auto row, so every inline flex:1 and alignSelf left in the JSX
     goes inert here. That is what makes the note-field starvation bug structurally
     impossible rather than merely patched. Scoped to .print-controls so the Master
     tab toolbar keeps its flex wrap. Nothing here can match inside .sheet. */
  .print-controls .toolbar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 10px;
    align-items: stretch;
  }
  .print-controls .toolbar > * { grid-column: 1 / -1; }
  .print-controls .toolbar > .ngipl-btn { grid-column: auto; }
  .print-controls .toolbar > .ngipl-btn.tb-wide { grid-column: 1 / -1; }
  .toolbar--tight { margin-bottom: 16px; }
  .f-input--client { width: 100%; }

  /* Row 1 of the quote panel is the one deliberate two-cell row: Add items with
     its count beside it, because that pair is one idea. Everything else spans. */
  .print-opts {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    gap: 12px 10px;
    align-items: center;
    padding: 12px;
  }
  .print-opts > * { grid-column: 1 / -1; }
  .print-opts .po-add { grid-column: 1; width: 100%; min-height: 44px; height: auto; }
  .print-opts .po-count { grid-column: 2; }
  .print-opts .po-clear { justify-self: end; min-height: 44px; height: auto; }
  .print-opts .po-confirm { flex-wrap: wrap; justify-content: flex-end; }
  .print-opts .po-confirm .ngipl-btn { min-height: 44px; height: auto; }

  /* Catalogue: four content-sized blocks ended at four different right edges.
     One column gives them all the same left margin and the same right edge. */
  .vc-controls {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin-bottom: 16px;
  }
  .vc-controls .spacer { display: none; }
  .vc-ctl .f-label { margin-bottom: 0; }
  .vc-ctl .caption { max-width: none; }
  .vc-ctl--actions {
    align-items: stretch;
    border-top: var(--bw-hairline) solid var(--border-default);
    padding-top: 16px;
  }
  .vc-actions { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 10px; }
  .vc-check { height: auto; min-height: 44px; gap: 10px; }
  .vc-check input[type="checkbox"] { width: 18px; height: 18px; flex: none; accent-color: var(--ngipl-black); }

  /* Segmented controls fill the measure. Anchored to an ancestor, never bare
     .seg, so they provably cannot reach a sheet. */
  .print-controls .toolbar .seg, .vc-ctl .seg { display: flex; width: 100%; }
  .print-controls .toolbar .seg button, .vc-ctl .seg button { flex: 1 1 0; min-width: 0; padding: 7px 6px; }

  /* 0,3,0 and 0,2,0 so both beat the 0,1,0 rules injected from js/ui.jsx, which
     land after this stylesheet. white-space: normal lets a long label wrap
     rather than clip on a 360px phone. */
  .print-controls .toolbar > .ngipl-btn,
  .vc-actions > .ngipl-btn {
    width: 100%;
    min-width: 0;
    min-height: 44px;
    height: auto;
    padding: 10px 12px;
    white-space: normal;
    line-height: 1.25;
    text-align: center;
  }

  /* touch targets, and 16px everywhere so iOS stops zooming the page on focus */
  .f-input, .f-select, .f-textarea { font-size: 16px; }
  .f-input, .f-select { height: 44px; }
  .f-input--sm { height: 44px; font-size: 16px; }
  .rate-input { font-size: 16px; width: 100%; min-width: 0; height: 40px; }
  .rate-view {
    display: inline-flex; align-items: center; justify-content: flex-end;
    min-height: 44px; min-width: 64px;
    border-bottom: none;
    text-decoration: underline dashed var(--gray-400);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
  }
  .rate-view:hover { text-decoration-color: var(--ngipl-black); }

  /* dialogs: f-row must stop being a squeezed 3-across */
  .dlg-scrim { padding: 12px 10px 28px; }
  .dlg-body { padding: 14px; }
  .f-row { flex-direction: column; gap: 12px; }
  .f-row > * { flex: none; }

  /* fold both data tables instead of scrolling them sideways.
     The hidden columns come back as .row-meta under the item name. */
  .col-no, .col-master, .col-unit, .col-pack, .col-outer, .col-gst { display: none; }
  .row-meta { display: block; }
  .admin-users .admin-act { width: auto !important; }
  .master-rows, .qq-rows { max-height: none; overflow: visible; }
  .sp-rows { max-height: none; min-height: 0; overflow: visible; }

  /* Special price list: one column, the price list first, the customers after it */
  .parties-grid { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .sp-customers, .sp-main { grid-column: 1; grid-row: auto; }
  /* With 97 items the price list is some ten thousand pixels tall on a phone, so the
     customers go above it, folded to one line until Show is tapped. */
  .sp-customers { order: -1; }
  .sp-cust-head { align-items: center; padding: 8px 8px 8px 14px; }
  .sp-cust-count { margin-left: 0; }
  .sp-cust-toggle { display: inline-flex; align-items: center; margin-left: auto; }
  .sp-cust-body { display: none; }
  .sp-customers--open .sp-cust-body { display: block; }
  /* Four columns on a phone: give the item name what the fixed ones can spare. */
  .sp-th-rate { width: 80px; }
  .sp-th-diff { width: 56px; }
  .sp-th-act { width: 48px; }
  .sp-rows .plm-table td:last-child, .sp-rows .plm-table th:last-child { padding-left: 0; padding-right: 4px; }
  .sp-search-box { flex: 1 1 100%; }
  .sp-stats .stat-cell { flex: 1 1 0; min-width: 0; padding: 10px 8px 10px 12px; }
  .sp-stats .stat-num { font-size: 20px; }
  .sp-banner { flex-wrap: wrap; }
  .sp-banner-text { flex: 1 1 calc(100% - 30px); }
  .sp-banner .ngipl-btn { flex: 1 1 100%; }
  .sp-cust-add .ngipl-btn { min-height: 44px; height: auto; }
  .sp-cust-edit-btns .ngipl-btn { min-height: 44px; height: auto; flex: 1; }
  .sp-setroute { min-height: 44px; }
  .sp-cust-row { padding-left: 12px; }
  .sp-cust-edit { height: 44px; }
  .sp-cust-list { max-height: none; }
  .sp-print-list .sp-print-btn { min-height: 44px; }
  /* the preview must not scroll sideways inside its panel on a phone */
  .sp-preview .plm-table td { padding-left: 8px; padding-right: 8px; }
  .sp-prev-old { width: 60px; }
  .sp-prev-arrow { width: 18px; }
  .sp-prev-new { width: 66px; }
  .sp-rows .plm-table th, .sp-rows .plm-table td { padding-left: 8px; padding-right: 8px; }
  /* The wrapper no longer scrolls (so sticky headers work), so a table wider than
     the screen would push the whole page sideways. At 320px the four remaining
     columns plus 12px gutters do exactly that. Tighten the gutters rather than
     dropping another column. Anchored to the row wrappers, which no sheet is inside. */
  .master-rows .plm-table th, .master-rows .plm-table td,
  .qq-rows .plm-table th, .qq-rows .plm-table td { padding-left: 8px; padding-right: 8px; }

  /* account chip and toast were overlapping each other at the bottom */
  #plm-cloud-chip { left: 8px; right: 8px; bottom: 8px; font-size: 11px; }
  #plm-sync-dot { flex: none; }
  /* shrink the email rather than hiding controls: sign out is the only way off a
     shared login, and the app allows one active session per account */
  #plm-cloud-chip > span + span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #plm-chpass { display: none; }
  #plm-signout { flex: none; min-height: 34px; }
  .toast-wrap { bottom: 64px; left: 12px; right: 12px; transform: none; }
  .toast { max-width: none; }

  /* controls the first touch pass missed. The date cell writes shared data on
     tap, so the popover goes full width of its field to buy cell size. */
  .cal-pop { left: 0; right: 0; width: auto; }
  .cal-day { height: 44px; font-size: 14px; }
  .seg button { min-height: 44px; }
  .fchip { min-height: 44px; }
}

/* Five tabs on a phone narrower than 380px (staff: Master, Special, Quote, Catalogue,
   Print): the same tightening the six-tab rule uses, so the last tab stays on screen. */
@media screen and (max-width: 380px) {
  .app-tabs:has(.app-tab:nth-child(5)) { gap: 8px; padding: 0 10px 1px; }
  .app-tabs:has(.app-tab:nth-child(5)) .app-tab { letter-spacing: 0.03em; font-size: 10.5px; }
}

@media print {
  body { background: #ffffff; }
  .app-chrome, .print-controls, .toast-wrap, .desk-doclabel, .view-toolbar, .row-actions, .drag-grip, .drag-ghost { display: none !important; }
  .vc-desk { background: none; border: none; padding: 0; overflow: visible; display: block; }
  .vc-sheet { border: none; width: auto; }
  .vc-card, .vc-band { break-inside: avoid; }
  .app-main { padding: 0; max-width: none; }
  .print-grid { display: block; }
  .print-desk { background: none; border: none; padding: 0; overflow: visible; }
  .sheet-scale { transform: none !important; height: auto !important; width: auto !important; }
  .sheet-canvas { padding: 0; overflow: visible; }
  .sheet { width: auto; min-height: 0; border: none; margin: 0; }
  .sheet tr { break-inside: avoid; }
  .sheet thead { display: table-header-group; }
}
@page { size: A4; margin: 8mm 9mm 10mm; }
