/* Shared presentation refinements. Workflow state and financial rules stay in the app. */
:root {
  --workspace-ink: #1b2c43;
  --workspace-muted: #586a80;
  --workspace-line: #e2e8f0;
  --workspace-accent: #1d4ed8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.skip-link { position: fixed; left: 1rem; top: -5rem; z-index: 100; background: #fff; color: #1d4ed8; border: 2px solid; border-radius: .5rem; padding: .75rem 1rem; }
.skip-link:focus { top: .75rem; }
:where(a, button, summary, input, select, textarea, [tabindex]):focus-visible { outline: 3px solid #2563eb; outline-offset: 3px; }
#main-content:focus { outline: none; }
[hidden] { display: none !important; }

body { color: var(--workspace-ink); background: #f5f7fa; line-height: 1.5; }
.site-header, .page-content { max-width: 1280px; }
.site-header { min-height: 4.5rem; border-bottom: 1px solid var(--workspace-line); padding-block: 1rem; }
.brand { font-size: .95rem; letter-spacing: .02em; }
.site-header nav { flex-wrap: wrap; justify-content: flex-end; }
.site-header form { margin: 0; }
.page-content { padding-top: 1.25rem; padding-bottom: 3rem; }
.workspace-heading { margin: 0 0 1.25rem; gap: 1rem; }
.workspace-heading > div { min-width: 0; }
.workspace-heading h1 { color: var(--workspace-ink); font-size: clamp(1.5rem, 2.6vw, 2rem); line-height: 1.3; letter-spacing: -.035em; margin-bottom: .4rem; }
.workspace-heading .muted { max-width: 48rem; line-height: 1.6; }
.eyebrow { color: var(--workspace-muted); font-size: .75rem; margin-bottom: .4rem; }
.content-card, .metric-card { border: 1px solid var(--workspace-line); border-radius: .9rem; box-shadow: 0 2px 5px rgb(25 46 78 / 3%); padding: 1.25rem; }
.content-card > .section-heading:first-child { margin-top: 0; }
.section-heading { gap: .75rem; margin-bottom: 1rem; }
.section-heading h2, .sales-performance-heading h2 { font-size: 1.18rem; line-height: 1.4; }
.section-heading > .muted { font-size: .78rem; max-width: 30rem; }
.button-link, .secondary-button { min-height: 2.65rem; font-size: .875rem; font-weight: 650; border-radius: .55rem; padding: .6rem .95rem; }
.secondary-button { border: 1px solid #d8e0ea; background: #fff; color: #34465d; }
.secondary-button:hover { background: #f1f5f9; }
.button-link:hover { background: #1741b5; }
button { border-radius: .55rem; }
button:disabled { cursor: not-allowed; opacity: .6; }
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="file"] { font-size: .8rem; }
input[type="file"]::file-selector-button { background: #f0f4fa; border: 1px solid #d5dfea; border-radius: .35rem; color: #334155; cursor: pointer; margin-right: .6rem; padding: .35rem .6rem; font: inherit; }

/* Compact module navigation leaves the first screen for actual work. */
.role-primary-nav, .warehouse-primary-nav { background: #eaf0f7; border: 1px solid #dfe6ef; border-radius: .8rem; gap: .35rem; margin: 0 0 .55rem; padding: .35rem; }
.role-primary-nav > a, .warehouse-primary-nav > a { align-items: center; background: transparent; border: 1px solid transparent; border-radius: .55rem; grid-template-columns: 2.1rem minmax(0, 1fr); gap: .65rem; min-height: 3.7rem; padding: .45rem .8rem; }
.role-primary-nav > a.is-current, .warehouse-primary-nav > a.is-current { background: #fff; border-color: #d7e2f2; box-shadow: 0 1px 4px rgb(25 46 78 / 6%); }
.role-primary-icon, .warehouse-primary-icon { border-radius: .55rem; height: 2.1rem; width: 2.1rem; font-size: .85rem; }
.role-primary-nav strong, .warehouse-primary-nav strong { font-size: .9rem; }
.role-primary-nav small, .warehouse-primary-nav small { color: var(--workspace-muted); font-size: .72rem; margin-top: .1rem; }
.role-secondary-nav, .warehouse-secondary-nav { gap: 1.25rem; scrollbar-width: thin; }
.role-secondary-nav a, .warehouse-secondary-nav a { font-size: .8rem; min-height: 2.8rem; padding-block: .65rem; }
.role-priority-card, .sales-status-summary article { box-shadow: none; border-radius: .75rem; }
.role-priority-card strong { font-size: 1.65rem; line-height: 1.25; }

/* Tables keep columns aligned; long identifiers wrap without stretching the page. */
.table-wrap { border: 1px solid var(--workspace-line); border-radius: .65rem; scrollbar-width: thin; }
.table-wrap table { margin: 0; }
th { background: #f3f6fa; color: #53657b; font-size: .78rem; font-weight: 650; }
th, td { padding: .85rem .9rem; vertical-align: middle; }
td { font-size: .875rem; }
td small { color: var(--workspace-muted); font-size: .75rem; line-height: 1.5; }
tbody tr:last-child td { border-bottom: 0; }
.numeric-cell { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.finance-review-table th:nth-child(n+9):nth-child(-n+11),
.finance-review-table td:nth-child(n+9):nth-child(-n+11),
.order-profit-table th:nth-child(3), .order-profit-table td:nth-child(3),
.order-profit-table th:nth-child(4), .order-profit-table td:nth-child(4),
.order-profit-table th:nth-child(6), .order-profit-table td:nth-child(6),
.order-profit-table th:nth-child(7), .order-profit-table td:nth-child(7) { text-align: right; white-space: nowrap; }
.finance-review-table td { vertical-align: top; }
.finance-review-table td:first-child { min-width: 13rem; max-width: 16rem; overflow-wrap: anywhere; }
.finance-review-table td:nth-child(14) { min-width: 13rem; max-width: 18rem; }
.table-scroll-hint { color: var(--workspace-muted); font-size: .78rem; margin: 0 0 .75rem; }
.table-cell-stack { display: grid; gap: .2rem; overflow-wrap: anywhere; }
.table-product { align-items: center; display: flex; gap: .75rem; min-width: 0; }
.table-product > img, .table-product > .catalog-placeholder { flex: 0 0 3.2rem; height: 3.2rem; width: 3.2rem; object-fit: contain; background: #f8fafc; border-radius: .55rem; }
.table-product > span:not(.catalog-placeholder) { display: grid; gap: .15rem; min-width: 0; overflow-wrap: anywhere; }
.workspace-status { background: #f1f5f9; border-radius: .4rem; color: #556478; display: inline-block; font-size: .75rem; padding: .3rem .55rem; white-space: nowrap; }
.workspace-status.is-active { background: #ecf7f0; color: #256543; }

/* Cost entry uses one row and one form per SKU on both desktop and mobile. */
.cost-table { min-width: 820px; table-layout: fixed; }
.cost-table th, .cost-table td { min-width: 0; }
.cost-table th:nth-child(1) { width: 29%; }
.cost-table th:nth-child(2) { width: 23%; }
.cost-table th:nth-child(3) { width: 13%; }
.cost-table th:nth-child(4) { width: 25%; }
.cost-table th:nth-child(5) { width: 10%; }
.cost-inline-form { align-items: center; gap: .5rem; grid-template-columns: minmax(0, 1fr) auto; min-width: 0; }
.cost-inline-form input { min-width: 0; text-align: right; padding: .5rem; }
.cost-inline-form button { font-size: .8rem; min-height: 2.75rem; padding: .5rem .65rem; white-space: nowrap; width: auto; }
.workspace-filter-tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; padding-bottom: 1rem; border-bottom: 1px solid var(--workspace-line); }
.workspace-filter-tabs a { color: #4a5d75; border: 1px solid transparent; border-radius: .5rem; font-size: .85rem; padding: .5rem .85rem; text-decoration: none; }
.workspace-filter-tabs a:hover { background: #f1f5f9; }
.workspace-filter-tabs a[aria-current="page"] { background: #edf3ff; border-color: #cfddf8; color: #1749b9; font-weight: 700; }
.table-action-disclosure { width: 18rem; }
.table-action-disclosure > summary { background: #eef4ff; border: 1px solid #cfddf8; border-radius: .5rem; color: #1d4ed8; cursor: pointer; font-weight: 650; padding: .6rem .75rem; }
.table-action-disclosure[open] > summary { margin-bottom: .8rem; }
.table-action-disclosure .finance-action-form { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: .6rem; padding: .8rem; }

.inventory-all-product-list { gap: .65rem; }
.inventory-all-product-row { background: #fff; border-radius: .65rem; margin: 0; padding: .85rem; }
.inventory-all-product-row:hover { background: #f8fafc; border-color: #c7d5e8; }
.inventory-product-identity strong { font-size: .875rem; }
.inventory-product-identity small { font-size: .75rem; }
.inventory-product-stock { margin-top: .2rem; }
.inventory-product-stock b { color: #1b365b; }
.inventory-all-product-actions { align-items: flex-end; flex-direction: column; gap: .2rem; }
.inventory-all-product-actions a { font-size: .75rem; min-height: 1.8rem; padding: .2rem; }
.inventory-catalog-total { font-size: .8rem; }
.inventory-catalog-total strong { font-size: 1.15rem; }
.inventory-priority-table .stock-number { font-size: 1rem; font-variant-numeric: tabular-nums; }
.inventory-row-actions { align-items: flex-start; }
.inventory-action-primary { display: inline-flex; min-height: 2.5rem; align-items: center; padding: .4rem .7rem; text-decoration: none; }
.inventory-row-more summary { min-height: 2.5rem; padding: .5rem .3rem; }

.sales-metric-card strong { font-size: clamp(1.35rem, 2.6vw, 1.9rem); letter-spacing: -.03em; }
.sales-performance-section { box-shadow: none; border-color: var(--workspace-line); }
.sales-quick-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sales-receivable-row { background: #fff; border-color: #dfe6ef; }
.sales-receivable-row.is-overdue { background: #fffbf4; border-color: #efcc9b; }
.sales-receivable-customer small { line-height: 1.6; }
.sales-goal-progress .section-heading { margin-top: 0; }
.ranking-list { padding-left: 0; list-style: none; }
.ranking-list li { border-bottom: 1px solid #edf1f6; padding: .75rem 0; }
.ranking-list li:last-child { border-bottom: 0; }
.order-form-modern .form-field > label, .order-form-modern .contact-parser > label { font-size: .82rem; }
.order-form-modern .form-hint { font-size: .75rem; }
.order-panel-heading p, .selected-product-cell small, .selected-empty small { font-size: .75rem; }
.selected-product-cell strong { white-space: normal; overflow-wrap: anywhere; }
.order-form-modern .money-input:focus-within { outline: 3px solid #2563eb; outline-offset: 2px; }

@media (max-width: 959px) and (min-width: 640px) {
  .sales-order-canvas { grid-template-columns: minmax(0, 1fr); }
  .order-summary-rail { position: static; }
}

@media (max-width: 820px) {
  .cost-table, .cost-table tbody { display: block; min-width: 0; }
  .cost-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .cost-table tr { display: grid; grid-template-columns: minmax(0, 1fr); padding: .9rem; gap: .6rem; }
  .cost-table tr + tr { border-top: 1px solid var(--workspace-line); }
  .cost-table td { display: flex; justify-content: space-between; align-items: center; gap: 1rem; border: 0; padding: 0; width: 100%; text-align: right; }
  .cost-table td[data-label]::before { content: attr(data-label); color: var(--workspace-muted); font-size: .78rem; flex: 0 0 6.5rem; text-align: left; }
  .cost-table .cost-product-cell { padding-bottom: .5rem; text-align: left; }
  .cost-inline-form { flex: 1; max-width: 22rem; }
  .cost-table td[colspan] { text-align: left; }
  .sales-quick-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sales-quick-stats div { border: 0; }
  .sales-quick-stats div:nth-child(n+3) { border-top: 1px solid #e8edf4; }
}

@media (max-width: 639px) {
  .site-header { align-items: center; padding: .8rem 1rem; min-height: 4rem; }
  .site-header nav { flex-direction: row; align-items: center; gap: .4rem; }
  .header-link { font-size: .75rem; white-space: normal; }
  .workspace-home-link { max-width: 10rem; padding: .45rem .55rem; }
  .header-logout { font-size: .75rem; min-height: 2.35rem; }
  .page-content { padding: 1.15rem .85rem 2rem; }
  .workspace-heading h1 { font-size: 1.5rem; }
  .content-card { padding: 1rem; }
  .section-heading h2 { font-size: 1.1rem; }
  .role-primary-nav > a, .warehouse-primary-nav > a { gap: .5rem; grid-template-columns: 1.8rem minmax(0, 1fr); padding: .5rem .4rem; min-height: 3.7rem; }
  .role-primary-icon, .warehouse-primary-icon { height: 1.8rem; width: 1.8rem; }
  .role-primary-nav strong, .warehouse-primary-nav strong { font-size: .82rem; }
  .role-primary-nav small, .warehouse-primary-nav small { font-size: .66rem; }
  .sales-metric-grid { grid-template-columns: minmax(0, 1fr); gap: .6rem; padding-inline: 1rem; }
  .sales-metric-card { align-items: center; display: grid; gap: .4rem .7rem; grid-template-columns: minmax(0, 1fr) auto; padding: 1rem; }
  .sales-metric-card strong { font-size: 1.5rem; margin: 0; }
  .sales-metric-card small { grid-column: 1 / -1; }
  .sales-goal-progress .section-heading, .sales-order-status-entry .section-heading { align-items: center; flex-direction: row; }
  .sales-order-status-entry .sales-text-link { font-size: .75rem; }
  .sales-receivable-row { column-gap: .6rem; }
  .sales-receivable-amount strong { font-size: 1rem; }
  .sales-quick-stats div { align-items: flex-start; flex-direction: column; gap: .3rem; }
  .inventory-all-product-row { grid-template-columns: 3rem minmax(0, 1fr) auto; gap: .5rem; }
  .inventory-all-product-actions { grid-column: auto; }
  .cost-inline-form { gap: .35rem; }
  .cost-inline-form button { padding: .5rem; }
  .cost-table td[data-label]::before { flex-basis: 5.2rem; }
  .cost-table td { gap: .6rem; }
  .order-form-modern input:not([type="checkbox"]), .order-form-modern select, .order-form-modern textarea { font-size: 1rem; }
}

/* Catalog quantities stay outside the checkbox label, so editing never unchecks a SKU. */
.order-form-modern .catalog-product-choice { cursor: pointer; display: grid; gap: 0; margin: 0; min-width: 0; }
.sku-card:focus-within { outline: 2px solid #1f7455; outline-offset: 2px; }
.catalog-product-grid { align-items: start; }
.order-form-modern .catalog-quantity { border-top: 1px solid #e4ece7; margin: .15rem .6rem .65rem; padding-top: .55rem; }
.order-form-modern .catalog-quantity > label { align-items: baseline; color: #405048; display: flex; font-size: .72rem; gap: .3rem; justify-content: space-between; margin: 0 0 .35rem; }
.catalog-quantity > label span { color: #728078; font-weight: 400; }
.order-form-modern .quantity-control { grid-template-columns: 2rem minmax(3.25rem, 1fr) 2rem; }
.order-form-modern .quantity-control input { min-width: 0; width: 100%; }
.order-form-modern .selected-sku-controls .quantity-control { width: 8.5rem; }
.order-form-modern .quantity-control input[aria-invalid="true"] { background: #fff1f2 !important; box-shadow: inset 0 0 0 1px #e11d48 !important; }
.order-form-modern .catalog-quantity .quantity-control { width: 100%; }
.order-form-modern .catalog-quantity .quantity-control button,
.order-form-modern .catalog-quantity .quantity-control input { min-height: 2.25rem !important; }
.order-form-modern:not(.is-enhanced) .catalog-quantity button { display: none; }
.order-form-modern:not(.is-enhanced) .catalog-quantity .quantity-control { grid-template-columns: 1fr; }

/* Compact sales catalog: smaller complete photos, readable names, unchanged controls. */
.order-form-modern .sku-toolbar { grid-template-columns: minmax(0, 1fr) 9rem; align-items: end; }
.order-form-modern .sku-toolbar label { font-size: .8rem; }
.catalog-effect-help { color: #65736c; font-size: .75rem; line-height: 1.5; margin: -.2rem 0 .8rem; }
.order-form-modern .catalog-product-grid { gap: .5rem; }
.order-form-modern .catalog-product-media { background: #f7f9f8; height: 4rem; margin: .55rem .55rem 0; }
.order-form-modern .catalog-product-media img { display: block; object-fit: contain; }
.order-form-modern .sku-card-check { left: .4rem; right: auto; }
.order-form-modern .sku-card-body { padding: .4rem .55rem .3rem; min-width: 0; }
.order-form-modern .sku-card-body strong { font-size: .82rem; line-height: 1.4; overflow-wrap: anywhere; }
.order-form-modern .sku-card-body span { font-size: .75rem; }
.order-form-modern .sku-card-body small { font-size: .68rem; overflow-wrap: anywhere; }
.order-form-modern .sku-card-body .catalog-effect-label { color: #52695e; font-size: .68rem; line-height: 1.4; }
.order-form-modern .sku-stock { font-size: .75rem; padding: 0 .55rem .45rem; }
.order-form-modern .catalog-quantity { margin-inline: .55rem; }
.catalog-category-group [data-visible-product-count] { font-weight: inherit; }
@media (max-width: 639px) {
  .order-form-modern .sku-toolbar { grid-template-columns: minmax(0, 1fr); }
  .order-form-modern .catalog-product-media { height: 3.5rem; }
  .order-form-modern .sku-card-body strong { font-size: .875rem; }
}

/* Only the catalog content scrolls; the selection/actions never leave the viewport. */
.order-form-modern.is-enhanced .catalog-drawer-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.order-form-modern.is-enhanced .catalog-drawer-heading { flex: 0 0 auto; }
.order-form-modern.is-enhanced .sku-picker {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}
.order-form-modern.is-enhanced .catalog-scroll-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  scrollbar-gutter: stable;
}
.order-form-modern.is-enhanced .catalog-category-groups { max-height: none; overflow: visible; }
.order-form-modern.is-enhanced .catalog-drawer-actions {
  bottom: auto;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  margin: 0;
  padding: .75rem 1rem max(.75rem, env(safe-area-inset-bottom, 0px));
  position: relative;
  z-index: 2;
}
.order-form-modern.is-enhanced .catalog-drawer-actions > div { margin-left: auto; }
.order-form-modern.is-enhanced .catalog-drawer-actions > span { font-variant-numeric: tabular-nums; }

/* Replenishment product search: keep long names readable and results local. */
.product-search-input-row { align-items: stretch; display: flex; gap: .5rem; }
.product-search-input-row input { flex: 1; min-width: 0; width: 100%; }
.product-search-input-row button { flex: 0 0 auto; width: auto; }
.product-search-results { border: 1px solid #cbd5e1; border-radius: .65rem; margin-top: .5rem; max-height: 17rem; overflow-y: auto; overscroll-behavior: contain; }
.product-search-results [role="option"] { background: #fff; border: 0; border-bottom: 1px solid #e5e7eb; border-radius: 0; color: #1e293b; display: block; font-size: .9rem; line-height: 1.6; min-height: 2.75rem; overflow-wrap: anywhere; padding: .7rem .85rem; text-align: left; width: 100%; }
.product-search-results [role="option"]:last-child { border-bottom: 0; }
.product-search-results [role="option"]:hover,
.product-search-results [role="option"][aria-selected="true"] { background: #edf7f2; color: #175d44; }
.product-search-input-row input[aria-invalid="true"] { border-color: #e11d48; }
.searchable-product > label { display: block; margin-bottom: .4rem; }
.product-search-enhanced .form-hint { margin-block: .5rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0s !important; animation-duration: 0s !important; }
}
