:root {
  --brand: #713126; --brand-dark: #5a271e; --brand-tint: #f4ebe9; --brand-tint-2: #e6d3cf; --brand-gray: #a4a8ad;
  --bg: #f1f1f1; --card: #fff; --nav: #eeeeee; --ink: #232323; --ink-2: #333333;
  --text: #232323; --muted: #535353; --border: #dddddd; --danger: #c62828; --ok: #1a7f4b;
  --radius: 12px; --shadow: 0 6px 24px rgba(0,0,0,.14);
}
* { box-sizing: border-box; }
html { background: #191919; }
html, body { margin: 0; min-height: 100%; font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--text); background: var(--bg); }
.hidden { display: none !important; }
body.pending .content { visibility: hidden; }   /* keep sidebar painted while session check runs */
h1 { margin: 0 0 6px; font-size: 22px; }
.muted { color: var(--muted); }
label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 0; }
input { font: inherit; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); }
input:focus { outline: 2px solid rgba(113,49,38,.25); border-color: var(--brand); }
button { font: inherit; cursor: pointer; border: 0; border-radius: 9px; padding: 10px 16px; background: var(--brand); color: #fff; font-weight: 600; }
button:hover { background: var(--brand-dark); }
button:disabled { opacity: .6; cursor: default; }
button.secondary { background: #fff; color: var(--brand); border: 1px solid var(--brand-tint-2); }
button.secondary:hover { background: var(--brand-tint); }

:root { --login-bg: linear-gradient(160deg, #232323 0%, #191919 55%, #713126 140%); }   /* same as the map app login */
.login-wrap { background: var(--login-bg); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 32px; width: 100%; max-width: 380px; }
.card .logo { display: block; max-width: 190px; height: auto; margin: 0 auto 18px; }
.card h1 { text-align: center; }
.card .sub { text-align: center; margin: 0 0 8px; }
.card button[type=submit] { width: 100%; margin-top: 20px; }
.notice { margin-top: 14px; padding: 9px 11px; border-radius: 9px; background: var(--brand-tint); color: var(--brand-dark); border: 1px solid var(--brand-tint-2); font-size: 14px; }
.error { margin-top: 14px; padding: 9px 11px; border-radius: 9px; background: #fdecec; color: var(--danger); border: 1px solid #f3c2c2; font-size: 14px; }

header.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px; background: var(--nav); border-bottom: 3px solid var(--brand); }
header.top img { height: 34px; width: auto; }
main.page { max-width: 900px; margin: 32px auto; padding: 0 20px; }
.panel { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--brand-tint); color: var(--brand); }
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }

/* App shell: left navigation */
body.app { display: flex; min-height: 100vh; }
.sidebar { width: 270px; flex-shrink: 0; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; background: var(--login-bg); color: #fff; padding: 24px 16px; }
.sidebar .brand img { display: block; max-width: 190px; height: auto; margin: 0 6px 28px; }
.nav-label { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand-gray); margin: 0 10px 8px; }
.nav-links { list-style: none; margin: 0; padding: 0; }
.nav-links a { display: block; padding: 11px 14px; font-size: 16px; border-radius: 9px; color: #e8e8e8; text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.nav-links a:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-links a.active { background: rgba(113,49,38,.55); color: #fff; border-left-color: #fff; }
.nav-foot { margin-top: auto; padding-top: 16px; border-top: 1px solid rgba(255,255,255,.12); font-size: 14px; }
.nav-foot .who { margin: 0 6px 10px; color: #e8e8e8; }
.nav-logout { width: 100%; background: rgba(255,255,255,.1); }
.nav-logout:hover { background: rgba(255,255,255,.2); }
main.content { flex: 1; padding: 32px 36px; min-width: 0; }
main.content h1 { margin-bottom: 18px; }
main.content h2 { margin: 0 0 6px; font-size: 18px; }
@media (max-width: 700px) { body.app { flex-direction: column; } .sidebar { width: auto; height: auto; position: static; } }

/* Tabs (Manage Inventory) */
.tabs { display: flex; gap: 4px; padding: 0 0 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tab { flex: 0 0 auto; min-width: 120px; border: 0; background: transparent; padding: 9px 16px; border-radius: 9px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; }
.tab:hover { background: var(--brand-tint); color: var(--brand); }
.tab.active { background: var(--brand); color: #fff; }
.tab.active:hover { background: var(--brand-dark); color: #fff; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }

/* Inventory tables & toolbar extras */
.toolbar { align-items: center; }
.link-btn { font: inherit; font-weight: 600; color: var(--brand); text-decoration: none; padding: 10px 4px; }
.link-btn:hover { text-decoration: underline; }
.table-wrap { overflow-x: auto; margin-top: 4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); vertical-align: top; }
.data-table th:last-child, .data-table td:last-child { border-right: 0; }
.data-table th { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; background: var(--brand-tint); }
.data-table tbody tr:nth-child(even) { background: #f0f0f0; }
.data-table tbody tr:hover { background: #faf7f6; }
/* Compact body rows in the Parts / Products tables (headers keep 10px); Reports use the same row height (wrapped cells still grow) */
#table-parts td, #table-products td, #table-customers td, #table-vendors td, #table-locations td, #report-table td { padding-top: 4px; padding-bottom: 4px; }

.empty-msg { margin: 18px 4px; }

/* Upload dialog */
.upload-dialog { border: 0; border-radius: var(--radius); box-shadow: var(--shadow); padding: 0; width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 40px); }
.upload-dialog::backdrop { background: rgba(0,0,0,.45); }
.upload-dialog form { margin: 0; padding: 24px 28px 20px; display: flex; flex-direction: column; gap: 10px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dlg-head h2 { margin: 0; font-size: 18px; }
.idle-dialog { width: min(420px, calc(100vw - 32px)); }
.idle-dialog p { margin: 0; }
.dlg-close { padding: 4px 12px; font-size: 22px; line-height: 1; min-width: 0; }
.file-label { margin: 0; }
.preview-wrap { margin-top: 4px; }
.preview-meta { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.preview-table-wrap { max-height: 260px; overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--border); }

/* Inventory filters */
.filters { display: flex; gap: 12px; align-items: flex-end; margin: 0 0 14px; width: 100%; }
.filters .filter-field { flex: 1 1 0; min-width: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); }
.filters .filter-field select,
.filters .filter-field input { width: 100%; margin: 0; font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); }
.filters .filter-field select:focus,
.filters .filter-field input:focus { outline: 2px solid rgba(113,49,38,.25); border-color: var(--brand); }


.dlg-template { margin: 0 0 12px; }

/* Editable inventory rows */
.data-table tbody tr.row-click { cursor: pointer; }
.data-table tbody tr.row-click:hover { background: var(--brand-tint); }

/* Edit dialog */
.edit-dialog { width: min(560px, calc(100vw - 32px)); }
.edit-dialog form { margin: 0; padding: 24px 28px 20px; display: flex; flex-direction: column; gap: 10px; }
.edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; }
/* Edit part dialog: Edit / Move tabs (same look as the page tabs) */
.dlg-tabs { padding-bottom: 10px; margin: 4px 0 4px; }
.dlg-pane { display: flex; flex-direction: column; gap: 10px; }
/* Panels stacked in one grid cell: the inactive one is invisible but still takes space, so switching tabs never changes the height */
.dlg-panes { display: grid; }
.dlg-panes > .dlg-pane { grid-area: 1 / 1; min-width: 0; }
.dlg-pane.pane-off { visibility: hidden; }
.move-info { margin: 0; font-weight: 600; }
.loc-qty-wrap { max-height: 158px; overflow-y: auto; border: 1px solid var(--border); }
.data-table.loc-qty { font-size: 13px; }
.data-table.loc-qty th, .data-table.loc-qty td { padding: 5px 10px; border-bottom: 1px solid var(--border); }
.data-table.loc-qty th { font-size: 12px; position: sticky; top: 0; }
.data-table.loc-qty tbody tr:last-child td { border-bottom: 0; }
.data-table.loc-qty tr.current td { font-weight: 600; }
.edit-grid label { margin: 0; }
.edit-grid .span-2 { grid-column: 1 / -1; }
.edit-grid textarea { font: inherit; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); resize: vertical; min-height: 72px; }
.edit-grid textarea:focus { outline: 2px solid rgba(113,49,38,.25); border-color: var(--brand); }
.edit-grid input[readonly], .edit-grid textarea[readonly] { background: #f7f7f7; color: var(--muted); }
.check-label { display: flex; align-items: center; gap: 8px; margin-top: 22px !important; font-size: 15px; color: var(--text); }
.check-label input { width: auto; margin: 0; }
@media (max-width: 520px) { .edit-grid { grid-template-columns: 1fr; } .check-label { margin-top: 8px !important; } }

/* Edit dialog: Location dropdown (disabled for now) */
.edit-grid select { font: inherit; width: 100%; margin-top: 4px; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); min-width: 0; }
.edit-grid select:focus { outline: 2px solid rgba(113,49,38,.25); border-color: var(--brand); }
.edit-grid select:disabled { background: #f7f7f7; color: var(--muted); cursor: not-allowed; opacity: 1; }

/* Customers and Vendors: buttons on the left, 300px search on the right, one row directly above the table */
#filters-customers, #filters-vendors { justify-content: space-between; flex-wrap: wrap; row-gap: 10px; }
#filters-customers .toolbar, #filters-vendors .toolbar { margin: 0; }
#filters-customers .filter-field, #filters-vendors .filter-field { flex: 0 1 300px; }
/* Locations: Create Location in a button row directly above the table, like Customers */
#filters-locations .toolbar { margin: 0; }

/* Inline field errors (customer, vendor and location dialogs) */
.field-error { display: block; margin-top: 4px; font-size: 13px; color: var(--danger); }
.edit-grid input.invalid { border-color: var(--danger); }
.edit-grid input.invalid:focus { outline-color: rgba(198,40,40,.25); border-color: var(--danger); }

/* State autocomplete */
.ac-wrap { position: relative; display: block; }
.ac-list { position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 2px); margin: 0; padding: 4px; list-style: none;
  background: #fff; border: 1px solid var(--brand-tint-2); border-radius: 9px; box-shadow: var(--shadow); max-height: 240px; overflow-y: auto; }
.ac-list li { padding: 7px 10px; border-radius: 7px; cursor: pointer; color: var(--text); font-size: 14px; }
.ac-list li b { display: inline-block; min-width: 28px; color: var(--brand); }
.ac-list li:hover { background: var(--brand-tint); }
.ac-list li.active { background: var(--brand); color: #fff; }
.ac-list li.active b { color: #fff; }

/* Sales Order: Create New (Purchase Order > Create New reuses these classes for the same look) */
.so-form { display: flex; flex-direction: column; gap: 18px; }
.so-section { border-bottom: 1px solid var(--border); padding-bottom: 18px; }
.so-section h3 { margin: 0 0 10px; font-size: 16px; color: var(--brand); }
.so-field { display: block; max-width: 520px; margin: 0 0 10px; }
.so-field input { width: 100%; margin-top: 4px; font: inherit; padding: 9px 11px; border: 1px solid var(--border); border-radius: 9px; background: #fff; color: var(--text); }
.so-field input:focus { outline: 2px solid rgba(113,49,38,.25); border-color: var(--brand); }
.so-field input.invalid { border-color: var(--danger); }
.req { color: var(--danger); }
.so-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: flex-start; }
.so-row .so-field { margin-bottom: 0; }
.so-customer-field { flex: 0 1 520px; max-width: 520px; min-width: 0; }   /* same width as the product search */
.so-customer-field .so-field { max-width: none; }
/* Full width; Ship to gets the widest column so typical addresses fit on one line; long values wrap (no truncation). */
.cust-details { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.4fr) max-content minmax(0, 1.6fr) auto;   /* Phone sized to "(555) 123-4567" */
  align-items: start; gap: 6px 18px; width: 100%; box-sizing: border-box; margin: 10px 0 0; padding: 8px 12px; border-left: 3px solid var(--brand);
  background: #fafafa; border-radius: 0 8px 8px 0; font-size: 13px; color: var(--text); }
.cust-details .cd { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cust-details .cd-val { overflow-wrap: anywhere; word-break: normal; white-space: normal; overflow: visible; text-overflow: clip; }
.cust-details .lbl { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.cust-details .cd-name { font-weight: 700; }
.cust-details .cd:nth-child(3) { padding-right: 14px; }   /* Phone: a little breathing room past max-content */
.cust-details .cd-change { align-self: center; justify-self: end; margin: 0; }
@media (max-width: 1040px) { .cust-details { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cust-details .cd-change { grid-column: 2; } }
@media (max-width: 720px) { .cust-details { grid-template-columns: minmax(0, 1fr); } .cust-details .cd-change { grid-column: auto; justify-self: start; } }
.so-link { background: none; border: 0; padding: 0 2px; font: inherit; font-size: 13px; font-weight: 600; color: var(--brand); text-decoration: underline; cursor: pointer; border-radius: 4px; }
.so-link:hover { background: none; color: var(--brand-dark); }
.so-link:focus-visible { outline: 2px solid rgba(113,49,38,.35); outline-offset: 1px; }
.ac-list li small { color: var(--muted); margin-left: 6px; }
.ac-list li.active small { color: #f4ebe9; }
.data-table.so-lines td { padding-top: 4px; padding-bottom: 4px; vertical-align: middle; }
/* Wide enough for the largest allowed values: a 9-digit quantity (plus spinner) or a cost such as 999999999.99. */
.so-lines input.so-qty { width: 130px; height: 20px; box-sizing: border-box; font: inherit; font-size: 13px; line-height: 1; padding: 0 8px; margin: 0; border: 1px solid var(--border); border-radius: 5px; display: block; }
.so-lines input.so-qty.invalid { border-color: var(--danger); }
.so-lines tr.over, .so-lines tbody tr.over:nth-child(even) { background: #fff4e5; }
.so-lines tr.over td.so-avail { color: #b45309; font-weight: 600; }
.so-lines button.so-remove { height: 20px; box-sizing: border-box; padding: 0 10px; margin: 0; font-size: 13px; line-height: 1; border-radius: 5px; display: block; }
.so-warn { margin: 8px 0 0; padding: 8px 11px; border-radius: 9px; background: #fff4e5; color: #8a4b08; border: 1px solid #f6d7a7; font-size: 14px; }
.success { padding: 9px 11px; border-radius: 9px; background: #e8f5ee; color: var(--ok); border: 1px solid #bfe3cf; font-size: 14px; }
.so-actions { display: flex; justify-content: flex-end; gap: 10px; }
.so-hint { margin: 0; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Sales Order > In-Progress: thin full-width order rows, click to expand */
.ip-heading { margin: 0 0 10px; font-size: 16px; color: var(--brand); }
.so-cards { display: flex; flex-direction: column; gap: 6px; }
.so-card { width: 100%; box-sizing: border-box; border: 1px solid var(--border); border-left: 3px solid var(--brand); border-radius: 0 9px 9px 0; background: var(--card); cursor: pointer; }
/* Short on inventory: same fill and text color as the table header rows */
.so-card.short { background: var(--brand-tint); }
.so-card.short, .so-card.short .so-card-date, .so-card.short .so-card-cust span { color: var(--muted); }
.so-card.short .so-card-num { color: var(--brand); }
/* Expanded short order: the product list stays white; only the short products are red (.bo below) */
.so-card.short .so-card-lines { background: var(--card); color: var(--text); border-radius: 0 0 9px 0; }
.so-card-row { display: flex; align-items: center; gap: 12px; padding: 4px 16px; min-height: 80px; box-sizing: border-box; }
.so-card-toggle { all: unset; flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 16px; font-size: 15px; line-height: 1.45; cursor: pointer; }
.so-card-toggle:hover { background: none; }
.so-card-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.so-chev { width: 0; height: 0; border-left: 5px solid var(--brand); border-top: 4px solid transparent; border-bottom: 4px solid transparent; flex: none; transition: transform .15s; }
.so-card.open .so-chev { transform: rotate(90deg); }
.so-card-num { font-weight: 700; color: var(--brand); white-space: nowrap; }
.so-card-date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.so-card-cust { flex: 1 1 14rem; font-weight: 600; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.so-card-cust span { font-weight: 400; color: var(--muted); }
.so-ship { flex: none; height: 30px; min-width: 76px; box-sizing: border-box; padding: 0 20px; margin: 0; font-size: 13px; line-height: 1; border-radius: 5px; display: block; }
.so-card-lines { list-style: none; margin: 0; padding: 4px 4px 8px 8px; border-top: 1px solid var(--border); display: grid; grid-template-columns: max-content minmax(0, 1fr) max-content; gap: 2px 0; align-items: stretch; font-size: 14px; }
.so-card-lines[hidden] { display: none; }
.so-card-lines li { display: contents; }
.so-card-lines li > span { padding: 1px 8px; }
.so-card-lines .sku { font-weight: 600; }
.so-card-lines .nm { min-width: 0; overflow-wrap: anywhere; }
.so-card-lines .qty { color: var(--muted); white-space: nowrap; }
/* Shipped tab: backordered (short) lines at the bottom, light red band across the row */
.so-card-lines .bo { background: var(--brand-tint); }
/* Purchase Order > In-Progress: same rows, with an Order Qty and a Cost column in the expanded list */
.so-card-lines.po-card-lines { grid-template-columns: max-content minmax(0, 1fr) max-content max-content; }

/* Ship dialog: the order's products like the expanded row, with an editable quantity and Remove */
.ship-cust { margin: 2px 0 0; font-size: 14px; }
.ship-dialog { width: min(860px, calc(100vw - 32px)); }
.ship-table td { padding-top: 4px; padding-bottom: 4px; vertical-align: middle; }
.ship-table td.sku { font-weight: 600; white-space: nowrap; }
.ship-table td.nm { overflow-wrap: anywhere; }
.ship-table .ship-qty-col { width: 1%; white-space: nowrap; }
.ship-table .ship-act-col { width: 1%; white-space: nowrap; text-align: right; }
.ship-table input.ship-qty { width: 130px; height: 30px; box-sizing: border-box; padding: 0 8px; margin: 0; }
.ship-table input.ship-qty.invalid { border-color: var(--danger); }
.ship-table button.ship-remove { height: 30px; box-sizing: border-box; padding: 0 14px; margin: 0; font-size: 13px; line-height: 1; border-radius: 5px; }
.ship-table tr.saving > * { opacity: .55; }
/* Delete Order: right-aligned just above the products table, danger styling */
button.danger { background: var(--danger); color: #fff; }
button.danger:hover { background: #a32020; }
button.danger:disabled:hover { background: var(--danger); }

/* Negative part quantity = shortage (sales orders allocate even when stock is short) */
.table td.neg, td.neg { color: var(--danger); font-weight: 600; }
.edit-grid input.neg { color: var(--danger); font-weight: 600; }
/* Parts with Quantity 0 (none on hand, or short): the whole row's text is red */
.data-table tbody tr.out td { color: var(--danger); }

/* Shipped tab: Print Invoice sits in the Ship button's spot */
.so-ship.so-print { white-space: nowrap; }

/* Sales Order Invoice: never shown on screen; printed alone when body has .print-invoice */
.invoice { display: none; }
@media print {
  @page { margin: 0; }   /* no browser-added date/title/URL; our own footer prints instead */
  body.print-invoice #invoice, body.print-receipt #receipt { padding: 14mm 14mm 22mm; box-sizing: border-box; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
  body.print-invoice .inv-foot, body.print-receipt .inv-foot { position: fixed; left: 14mm; right: 14mm; bottom: 8mm; margin: 0; }
  body.print-invoice, body.print-receipt { background: #fff; display: block; }
  body.print-invoice > *:not(#invoice) { display: none !important; }
  body.print-receipt > *:not(#receipt) { display: none !important; }
  body.print-invoice #invoice, body.print-receipt #receipt { display: block; }
}
.invoice { color: var(--ink); font: 13px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv-head { display: flex; justify-content: space-between; align-items: center; gap: 24px; padding-bottom: 12px; border-bottom: 3px solid var(--brand); }
.inv-logo { height: 48px; width: auto; }
.inv-title { text-align: right; align-self: flex-end; }
.inv-title h1 { margin: 0; font-size: 22px; color: var(--brand); }
.inv-title p { margin: 2px 0 0; font-size: 15px; font-weight: 700; }
.inv-info { display: flex; justify-content: space-between; gap: 32px; margin: 18px 0; }
.inv-meta { margin: 0; display: grid; grid-template-columns: max-content; gap: 6px; }
.inv-meta div { display: flex; gap: 12px; }
.inv-meta dt, .inv-shipto h2 { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 0; }
.inv-meta dt { min-width: 92px; padding-top: 1px; }
.inv-meta dd { margin: 0; font-weight: 600; }
.inv-shipto { min-width: 220px; max-width: 50%; }
.inv-shipto h2 { margin-bottom: 4px; }
.inv-shipto div div { overflow-wrap: anywhere; }
.inv-shipto .inv-shipto-name { font-weight: 700; }
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table th, .inv-table td { text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.inv-table thead th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: var(--brand-tint); }
.inv-table td:first-child { font-weight: 600; white-space: nowrap; }
.inv-table .num { text-align: right; white-space: nowrap; width: 1%; }
.inv-table tfoot th, .inv-table tfoot td { font-weight: 700; border-top: 2px solid var(--ink); border-bottom: 0; }
.inv-table tr { break-inside: avoid; }
/* Short (backordered) rows: forced to the bottom, light red like the short rows and table headers */
.inv-table tr.inv-short td { background: var(--brand-tint); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
.inv-bo { display: block; margin-top: 1px; font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand); }
.inv-table tfoot tr.inv-short-total th, .inv-table tfoot tr.inv-short-total td { border-top: 0; font-weight: 600; color: var(--brand); padding-top: 2px; }
.inv-table tfoot tr[hidden] { display: none; }
.inv-foot { margin-top: 28px; padding-top: 8px; border-top: 1px solid var(--border); color: var(--muted); font-size: 11px; display: flex; justify-content: space-between; gap: 16px; }

/* Shipped: heading on the left, 300px search on the right */
.sh-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.sh-head .ip-heading { margin: 0; }
.sh-head .filter-field { flex: 0 1 300px; }
.so-cards > [hidden] { display: none; }

/* Receiving Receipt (Purchase Order): same template as the invoice, plus section labels */
.rcp-section { margin: 20px 0 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; }
.rcp-section .rcp-bo { color: var(--brand); font-weight: 700; }
.rcp-nothing { margin: 0; font-weight: 600; }
#rcp-wait-table tbody td { background: var(--brand-tint); -webkit-print-color-adjust: exact; print-color-adjust: exact; }
#rcp-wait-table[hidden], .rcp-nothing[hidden] { display: none; }

/* Purchase Order cards: "Backorder of PO-…" label next to the number */
.po-bo-tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--brand); background: var(--brand-tint); border-radius: 5px; padding: 1px 7px; }

/* Reconcile Order dialog */
.rc-table .num { text-align: right; }
.rc-table th .th-hint { display: block; font-size: 11px; text-transform: none; letter-spacing: 0; font-weight: 400; }
.ship-table input.ship-qty:disabled { background: var(--bg); color: var(--muted); }

/* Reports: Choose Report on the left, downloads on the right */
.report-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.report-head .filters { width: auto; min-width: 0; max-width: 100%; flex: 0 1 auto; margin: 0; }
/* Fixed 300px (like the Vendors/Customers filters) so the dropdown does not shrink to its text while the date range is hidden. */
#filters-reports > .filter-field { flex: 0 1 300px; width: 300px; max-width: 100%; }
.report-range { flex-wrap: wrap; row-gap: 10px; }   /* own row under Choose Report / downloads, so showing it moves nothing */
.report-range .filter-field { flex: 0 0 165px; }
.report-range .filter-field.report-filter { flex: 1 1 130px; max-width: 240px; align-self: stretch; }   /* Customer / Product dropdowns (Customer Order History): share the row with the dates + Clear, up to 240px each */
.report-range .report-filter-box { flex: 1 0 auto; display: flex; }   /* stretched to the date inputs' height on the same line */
.report-range .report-filter-box input { flex: 1 1 auto; min-width: 0; padding-right: 30px; text-overflow: ellipsis; }
.report-range .report-filter-box input.pending { border-color: var(--brand-gray); }   /* typed text not applied yet */
.report-filter-x { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); min-width: 0; width: 24px; height: 24px; padding: 0; border: 0;
  border-radius: 50%; background: transparent; color: var(--muted); font-size: 18px; line-height: 24px; cursor: pointer; }
.report-filter-x:hover, .report-filter-x:focus-visible { background: var(--brand-tint); color: var(--brand); }
#report-clear { padding-top: 9px; padding-bottom: 9px; }   /* same height as the date inputs */
.report-head .report-downloads { margin: 0; }
.report-table .num { text-align: right; white-space: nowrap; }
/* PO numbers, dates, SKUs and numbers stay on one line; long text columns (Vendor, Part Name) wrap instead of widening the
   table, and headings may wrap onto two lines when the window is tight. */
.report-table td { white-space: nowrap; }
.report-table th { white-space: normal; }
.report-table td.wrap { white-space: normal; min-width: 96px; max-width: 280px; overflow-wrap: anywhere; }
/* Group heading row (e.g. 'SKU - Product Name' in Customer Order History): one bold cell across the table, light brand tint
   (lighter than the column headings; same tint in the PDF), not striped or hover-shaded like the data rows. */
/* A report with stripes: false (Customer Order History): data rows keep the plain card background (hover still shades). */
.report-table.no-stripes tbody tr:not(:hover) { background: var(--card); }
/* Group total row (Customer Order History: Total QTY Shipped per product): bold, a subtle gray rule along its top (an inset
   shadow, since in the collapsed table the row above's own bottom border would win; no change to the row height). */
.report-table tbody tr.report-total td { font-weight: 700; box-shadow: inset 0 1px 0 var(--brand-gray); }
/* No row line under a Total (transparent, not removed, so the row keeps its height; the spacer below draws no top line). */
.report-table tbody tr.report-total td { border-bottom-color: transparent; }
/* Spacer between one product's Total and the next heading: 14px of blank card, inert (aria-hidden in reports.js); only its bottom
   border, so the heading keeps its usual top line and row height. */
.report-table tbody tr.report-gap, .report-table tbody tr.report-gap:hover { background: var(--card); pointer-events: none; }
.report-table tbody tr.report-gap td { height: 14px; padding: 0; border: 0; border-bottom: 1px solid var(--border); background: var(--card); }
/* Indented column (Customer Order History customers, nested under the product heading): 20px more than the 12px cell padding. */
.report-table td.indent { padding-left: 32px; }
/* fit: true reports (Customer Order History): a non-flex column shrinks to its widest value (header on one line), so the flex
   column (Customer) takes the spare width, as in the PDF. */
.report-table th.fit { width: 1%; white-space: nowrap; }
.report-table tbody tr.report-group td, .report-table tbody tr.report-group:hover td { font-weight: 700; color: var(--ink); background: #f9f4f3; white-space: normal; overflow-wrap: anywhere; }

/* Dashboard: the two count cards stacked in one column (solid Proguard maroon: title + icon, big number, 'View in-progress ->')
   beside the Reorder Watchlist (two columns wide, as tall as both cards, scrolls inside) */
main.content .dash-welcome { margin: 0 0 16px; font-size: 16px; font-weight: 600; color: var(--muted); }
.dash-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(2, 180px); gap: 20px; }
#dash-so { grid-column: 1; grid-row: 1; }
#dash-po { grid-column: 1; grid-row: 2; }
.dash-card { display: grid; grid-template-columns: 1fr auto; grid-template-rows: auto 1fr auto; align-items: center; padding: 20px 24px; text-decoration: none; color: #fff;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); transition: box-shadow .15s; }
.dash-card:hover { box-shadow: 0 10px 30px rgba(113,49,38,.35); }
.dash-card:focus-visible { outline: 3px solid rgba(113,49,38,.55); outline-offset: 2px; }
main.content .dash-title { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 600; margin: 0; }
main.content .dash-card .dash-title { grid-column: 1; grid-row: 1; color: rgba(255,255,255,.88); font-size: 14px; }
.dash-icon { grid-column: 2; grid-row: 1; width: 40px; height: 40px; border-radius: 10px; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; }
.dash-count { grid-column: 1 / -1; grid-row: 2; margin: 0; font-size: 54px; line-height: 1; font-weight: 700; color: #fff; font-variant-numeric: tabular-nums; }
.dash-view { grid-column: 1 / -1; grid-row: 3; font-size: 13px; font-weight: 600; color: rgba(255,255,255,.85); }
.dash-arrow { display: inline-block; transition: transform .15s; }
.dash-card:hover .dash-arrow { transform: translateX(4px); }
.dash-note { grid-column: 1 / -1; grid-row: 3; font-size: 13px; color: #ffd9d4; }   /* count didn't load: replaces 'View in-progress' */
.dash-card:has(.dash-note:not(.hidden)) .dash-view { display: none; }
.dash-watch { grid-column: 2 / span 2; grid-row: 1 / span 2; display: flex; flex-direction: column; min-height: 0; padding: 22px 24px; }
.dash-watch-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.dash-watch-sub { font-size: 13px; }
.dash-watch-head + .error { margin-top: 0; }
.dash-watch-wrap { flex: 1 1 auto; min-height: 0; overflow: auto; border: 1px solid var(--border); border-radius: 9px; }
.dash-watch-table th { position: sticky; top: 0; z-index: 1; }
.dash-watch-table th, .dash-watch-table td { padding: 6px 10px; }
.dash-watch-table tr:last-child td { border-bottom: 0; }
.dash-watch-table th, .dash-watch-table td:not(.wrap) { white-space: nowrap; }   /* headings + numbers on one line; the name wraps */
.dash-watch-table td.wrap { overflow-wrap: break-word; min-width: 120px; }
.dash-watch-table .dash-loc { display: block; font-size: 12px; color: var(--muted); }
/* narrower: the two cards side by side, the watchlist full width below; phone: everything stacked */
@media (max-width: 1100px) { .dash-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; }
  #dash-so, #dash-po { grid-column: auto; grid-row: auto; min-height: 150px; } .dash-watch { grid-column: 1 / -1; grid-row: auto; height: 380px; } }
@media (max-width: 520px) { .dash-grid { grid-template-columns: minmax(0, 1fr); } .dash-count { font-size: 48px; } }
