:root {
    color-scheme: light;
    --navy: #13233a;
    --navy-light: #1d3352;
    --blue: #2f6fed;
    --blue-soft: #edf4ff;
    --ink: #172033;
    --muted: #687386;
    --line: #e3e8ef;
    --surface: #ffffff;
    --background: #f4f6f9;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
    font-optical-sizing: auto;
}

.catalog-picker { margin-bottom: 18px; }
.catalog-search-row { display: grid; grid-template-columns: 2fr 1fr 1fr auto; gap: 12px; align-items: end; }
.catalog-search-row label { display: grid; gap: 6px; }
.catalog-results { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; margin-top: 14px; }
.catalog-result { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.catalog-result.selected { border-color: var(--blue); box-shadow: 0 0 0 2px rgb(47 111 237 / 20%); }
.catalog-result p { margin: 6px 0; }
.catalog-result small { display: block; margin-bottom: 10px; }
.catalog-image { display: grid; gap: 6px; align-content: start; }
.catalog-image img { width: 100%; border-radius: 7px; aspect-ratio: 488 / 680; object-fit: cover; }
.catalog-image .button { padding: 6px; font-size: .72rem; }
.catalog-image-missing { display: grid; place-items: center; min-height: 150px; padding: 8px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 7px; }
.stock-reference { font-weight: 800; letter-spacing: .03em; }

@media (max-width: 760px) {
    .catalog-search-row { grid-template-columns: 1fr; }
    .catalog-result { grid-template-columns: 90px minmax(0, 1fr); }
}

.order-position-table thead th { position: sticky; top: 72px; z-index: 8; background: #fff; box-shadow: 0 1px 0 var(--line); }
.order-position-table { min-width: 900px; }
.order-position-table tr.position-row { display: table-row; }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(18rem, .7fr); gap: 1rem; align-items: start; }
.workspace-grid fieldset { display: grid; gap: .75rem; border: 1px solid #d9e0e8; border-radius: .65rem; margin: 0 0 1rem; padding: 1rem; }
.workspace-grid > .panel, .workspace-grid .form-grid > fieldset { min-width: 0; }
.workspace-grid > .panel:first-child { grid-column: 1 / -1; }
.workspace-grid .form-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: start; }
.workspace-grid .form-grid > fieldset { align-content: start; }
.workspace-grid .form-grid input, .workspace-grid .form-grid select { min-height: 2.25rem; }
.workspace-grid .form-grid > .button { justify-self: start; }
.purchase-overview { padding: 18px 28px; }
.purchase-overview > summary { display: flex; align-items: baseline; gap: 14px; cursor: pointer; list-style: none; }
.purchase-overview > summary::-webkit-details-marker { display: none; }
.purchase-overview > summary::before { content: "›"; color: var(--blue); font-size: 1.25rem; font-weight: 800; transform: rotate(0); transition: transform .15s ease; }
.purchase-overview[open] > summary::before { transform: rotate(90deg); }
.purchase-overview-title { font-size: 1.15rem; font-weight: 700; }
.purchase-overview-preview { color: var(--muted); font-size: .8rem; }
.purchase-overview .metric-grid { margin-top: 18px; }
@media (min-width: 1281px) {
    /* Preserve the shared page cap; only this panel uses the 244px-sidebar desktop workspace with 40px gutters. */
    .purchase-working-area { position: relative; left: 50%; width: min(2200px, calc(100vw - 324px)); transform: translateX(-50%); }
    .sales-matching-page { position: relative; left: 50%; width: min(1800px, calc(100vw - 324px)); transform: translateX(-50%); }
    .content:has(> .accounting-page) { max-width: 1980px; }
    .accounting-page { width: 100%; }
    .purchase-position-table { min-width: 0; table-layout: fixed; }
    .purchase-position-table th, .purchase-position-table td { white-space: normal; overflow-wrap: anywhere; }
    .purchase-position-table th:nth-child(1) { width: 13%; }
    .purchase-position-table th:nth-child(2) { width: 11%; }
    .purchase-position-table th:nth-child(3) { width: 18%; }
    .purchase-position-table th:nth-child(4) { width: 12%; }
    .purchase-position-table th:nth-child(5) { width: 10%; }
    .purchase-position-table th:nth-child(6) { width: 36%; }
}
.workspace-grid .purchase-form { display: block; }
.purchase-primary-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.purchase-form fieldset { align-content: start; margin: 0; }
.form-field { display: grid; gap: 6px; min-width: 0; color: var(--muted); font-size: .78rem; font-weight: 700; }
.form-field[hidden] { display: none; }
.field-caption { display: flex; align-items: center; min-height: 18px; gap: 4px; }
.field-caption .help-control { margin-left: 0; }
.required-marker { color: #b42318; font-weight: 900; }
.required-legend { margin: 0 0 14px; color: var(--muted); font-size: .78rem; }
.form-field > input, .form-field > select, .form-field > textarea { width: 100%; min-height: 2.25rem; padding: 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background: white; }
.form-field > textarea { resize: vertical; }
.form-disclosure { margin-top: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fafbfd; }
.form-disclosure > summary { padding: 11px 14px; cursor: pointer; color: var(--blue); font-size: .82rem; font-weight: 700; }
.purchase-disclosure-grid { display: grid; grid-template-columns: minmax(0, .65fr) minmax(0, 1.35fr); gap: 14px; padding: 0 14px 14px; }
.purchase-disclosure-grid fieldset:last-child { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.purchase-disclosure-grid.purchase-lot-detail { grid-template-columns: minmax(0, 1fr); }
.purchase-lot-detail > section { min-width: 0; }
.purchase-lot-detail .business-details { grid-template-columns: max-content minmax(0, 1fr); }
.purchase-lot-detail .business-details dd,
.purchase-lot-detail code { overflow-wrap: anywhere; }
.purchase-lot-detail .mini-form,
.purchase-lot-detail .mini-form > * { min-width: 0; max-width: 100%; }
.purchase-position-table-wrap { max-width: 100%; scrollbar-gutter: stable; }
.purchase-position-table { min-width: 1120px; }
.purchase-article-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; padding: 0 14px 14px; }
.purchase-article-grid .article-notes { grid-column: span 2; }
.purchase-form > .button { margin-top: 14px; }
.inventory-search > label { display: block; font-weight: 700; margin-bottom: .45rem; }
.search-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .6rem; }
.search-row input { min-width: 0; }
.filter-panel { margin-top: 1rem; }
.active-filters span { display: inline-block; background: #eef3f8; border-radius: 999px; padding: .2rem .55rem; margin: .2rem; }
.table-wrap.inventory-table-wrap { overflow: visible; }
.inventory-compact { min-width: 0; }
.inventory-compact thead th { position: sticky; top: 72px; z-index: 8; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.inventory-compact th, .inventory-compact td { white-space: normal; overflow-wrap: anywhere; }
.inventory-compact td small, .inventory-compact td strong { display: block; }
.business-details { display: grid; grid-template-columns: max-content 1fr; gap: .3rem .8rem; }
.inventory-actions { text-align: right; }
.inventory-detail-row > td { padding: 0 12px 16px; background: #f8fafc; white-space: normal; }
.inventory-detail-content { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(240px, .6fr); gap: 18px 28px; padding: 18px; border-left: 3px solid #b9cff8; }
.inventory-detail-content h3 { margin: 0 0 14px; font-size: .95rem; }
.inventory-detail-content .business-details { margin: 0; }
.inventory-mobile-details { display: none; }
.inventory-review-form { align-content: start; min-width: 0; }
.inventory-detail-content > .system-details { grid-column: 1 / -1; }
.inventory-detail-content .technical-details { margin-bottom: 0; }
.inline-actions { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; }
.variant-dialog { width: min(30rem, calc(100% - 2rem)); border: 0; border-radius: .8rem; box-shadow: 0 1rem 4rem #0004; }
.variant-dialog::backdrop { background: #17203399; }
@media (max-width: 1280px) { .workspace-grid .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) { .workspace-grid { grid-template-columns: minmax(0, 1fr); } }

@media (max-width: 900px) {
    .purchase-lot-detail .business-details { grid-template-columns: minmax(0, 1fr); gap: .2rem; }
    .purchase-lot-detail .business-details dd { margin: 0 0 .5rem; }
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--background); font-optical-sizing: auto; }
a { color: inherit; }
.app-shell { min-height: 100vh; display: grid; grid-template-columns: 244px minmax(0, 1fr); }
.sidebar { min-height: 100vh; padding: 28px 18px; display: flex; flex-direction: column; color: #d8e2f0; background: var(--navy); }
.brand { display: flex; align-items: center; gap: 12px; padding: 0 10px 30px; color: white; text-decoration: none; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: var(--blue); font-weight: 800; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 1.05rem; letter-spacing: .04em; }
.brand small { margin-top: 2px; color: #91a2ba; font-size: .72rem; }
nav { display: grid; gap: 6px; }
nav a { min-height: 44px; padding: 11px 13px; display: flex; align-items: center; border-radius: 8px; color: #b8c5d6; text-decoration: none; font-size: .92rem; font-weight: 600; }
nav a:hover, nav a:focus-visible { color: white; background: var(--navy-light); }
nav a:focus-visible { outline: 2px solid white; outline-offset: 2px; }
nav a.active { color: white; background: var(--blue); }
.sidebar-footer { margin-top: auto; padding: 18px 10px 0; border-top: 1px solid #2b3c55; color: #91a2ba; font-size: .78rem; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 7px; border-radius: 50%; background: #53c28b; }
main { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 9; height: 72px; padding: 0 40px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); background: var(--surface); }
.environment { font-size: .85rem; font-weight: 650; color: var(--muted); }
.local-badge { padding: 6px 10px; border-radius: 999px; color: #236747; background: #e8f7ef; font-size: .75rem; font-weight: 700; }
.content { width: 100%; max-width: 1280px; min-width: 0; margin: 0 auto; padding: 46px 40px; }
.page-heading { margin-bottom: 30px; }
.eyebrow { margin: 0 0 8px; color: var(--blue); font-size: .72rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(1.8rem, 3vw, 2.35rem); letter-spacing: -.035em; }
.page-heading > p:last-child, .welcome-panel p, .empty-state p { color: var(--muted); line-height: 1.6; }
.status-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 18px; }
.status-card { min-height: 180px; padding: 22px; display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); box-shadow: 0 5px 18px rgba(25, 39, 66, .04); }
.card-label { margin-bottom: 24px; color: var(--muted); font-size: .78rem; font-weight: 750; text-transform: uppercase; letter-spacing: .04em; }
.status-card strong { line-height: 1.4; }
.status-card a { margin-top: auto; padding-top: 20px; color: var(--blue); font-size: .82rem; font-weight: 700; text-decoration: none; }
.welcome-panel, .empty-state { margin-top: 24px; padding: 28px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.welcome-panel { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.welcome-panel h2, .empty-state h2 { margin-bottom: 8px; font-size: 1.15rem; }
.welcome-panel p { max-width: 700px; margin-bottom: 0; }
.button { flex: none; padding: 11px 16px; border-radius: 8px; color: white; background: var(--blue); font-size: .84rem; font-weight: 700; text-decoration: none; }
.empty-state { display: flex; align-items: center; gap: 18px; }
.empty-state p { margin-bottom: 0; }
.empty-icon { flex: none; width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; color: var(--blue); background: var(--blue-soft); font-weight: 800; }
.panel { margin-top: 24px; padding: 28px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface); }
.panel h2 { margin-bottom: 18px; font-size: 1.15rem; }
.import-form { display: flex; align-items: end; gap: 18px; flex-wrap: wrap; }
.import-form label { display: grid; gap: 7px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.import-form select, .import-form input { min-width: 240px; padding: 10px; border: 1px solid var(--line); border-radius: 7px; background: white; color: var(--ink); }
button.button { border: 0; cursor: pointer; }
.alert { padding: 14px 18px; border: 1px solid #efb5b5; border-radius: 9px; color: #842b2b; background: #fff0f0; }
.alert.success { border-color: #92c9ac; color: #23583b; background: #effaf4; }
.alert a { margin-left: 8px; font-weight: 700; }
.alert code { white-space: normal; overflow-wrap: anywhere; }
.table-wrap { max-width: 100%; min-width: 0; overflow-x: auto; }
.table-wrap[tabindex="0"]:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }
.accounting-tax-table { width: 100%; table-layout: fixed; }
.accounting-tax-table th, .accounting-tax-table td { white-space: normal; overflow-wrap: anywhere; vertical-align: top; }
.accounting-tax-table th:nth-child(1) { width: 12%; }
.accounting-tax-table th:nth-child(2) { width: 17%; }
.accounting-tax-table th:nth-child(3), .accounting-tax-table th:nth-child(4), .accounting-tax-table th:nth-child(5), .accounting-tax-table th:nth-child(6) { width: 10%; }
.accounting-tax-table th:nth-child(7) { width: 11%; }
.accounting-tax-table th:nth-child(8) { width: 20%; }
.money-cell { text-align: right; font-variant-numeric: tabular-nums; }
.money-cell small { text-align: right; }
.refund-review-table { min-width: 58rem; }
.refund-review-table th:nth-child(1) { width: 31%; }
.refund-review-table th:nth-child(2) { width: 13%; }
.refund-review-table th:nth-child(3) { width: 21%; }
.refund-review-table th:nth-child(4) { width: 13%; }
.refund-review-table th:nth-child(5) { width: 22%; }
.refund-review-table th, .refund-review-table td { white-space: normal; }
.refund-review-table td:first-child strong, .refund-review-table td:first-child small { display: block; }
.refund-review-table form { min-width: 0; }
.export-actions { margin: 24px 0; padding: 20px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 24px; border: 1px solid var(--line); border-radius: 10px; background: var(--background); }
.export-actions > * { min-width: 0; max-width: 100%; }
.export-actions > :first-child { flex: 1 1 24rem; }
.export-actions .page-actions { min-width: 0; max-width: 100%; }
.export-actions .button { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.export-actions h3 { margin: 0 0 7px; }
.export-actions p { margin: 0; }
/* The page must remain the sticky header's vertical scroll container. */
.table-wrap.order-table-wrap { overflow: visible; }
table { width: 100%; border-collapse: collapse; font-size: .86rem; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { color: var(--muted); font-size: .72rem; text-transform: uppercase; }
.muted { color: var(--muted); }
.metadata dl { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.metadata dl div { min-width: 0; }
.metadata dt { margin-bottom: 5px; color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.metadata dd { margin: 0; overflow-wrap: anywhere; }
.metadata code { font-size: .78rem; }
.hint { margin: 16px 0 0; }
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; }
.form-grid label, .mini-form { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.form-grid input, .form-grid select, .mini-form input, .mini-form select, .mini-form textarea, table select { width: 100%; padding: 8px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.mini-form { min-width: 220px; }
button:disabled { opacity: .45; cursor: not-allowed; }
.panel-title { display: flex; justify-content: space-between; align-items: start; gap: 20px; }
.panel-title > * { min-width: 0; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric-grid div { padding: 15px; border-radius: 9px; background: var(--background); }
.metric-grid span, .metric-grid strong { display: block; }
.metric-grid span { min-height: 2.4em; color: var(--muted); font-size: .75rem; }
.metric-grid strong { margin-top: 7px; font-size: 1.05rem; }
.bounded { max-height: 420px; overflow: auto; }
td.wrap { white-space: normal; min-width: 320px; }
.empty-state { display: block; padding: 9px 0; color: var(--muted); font-weight: 400; }
.technical-details { display: grid; grid-template-columns: max-content 1fr; gap: 7px 16px; padding: 12px 0; }
.technical-details dt { color: var(--muted); font-weight: 700; }
.technical-details dd { margin: 0; overflow-wrap: anywhere; }
.technical-details-disclosure { margin-top: 7px; font-size: .75rem; }
.technical-details-disclosure summary { color: var(--muted); cursor: pointer; font-weight: 700; }
.technical-details-disclosure summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.technical-details-disclosure code { overflow-wrap: anywhere; white-space: normal; }
.tax-finalization-workflow { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.tax-finalization-disclosure { margin-top: 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--background); }
.tax-finalization-disclosure > summary { min-height: 44px; padding: 11px 14px; display: flex; align-items: center; cursor: pointer; }
.tax-finalization-form { min-width: 0; padding: 0 14px 14px; }
.tax-finalization-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.tax-finalization-fields label { min-width: 0; display: grid; gap: 6px; }
.tax-finalization-confirm { min-height: 44px; display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 600; }
.tax-finalization-confirm input { width: auto; flex: none; }
.tax-finalization-form .button { min-height: 44px; justify-self: start; }
.tax-finalization-disclosure > summary:focus-visible, .tax-finalization-form input:focus-visible, .tax-finalization-form textarea:focus-visible, .tax-finalization-form .button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.help-label { display: inline; color: inherit; font: inherit; text-transform: inherit; }
.help-field { position: relative; display: flex; min-width: 0; gap: 4px; align-items: start; }
.help-field > label { display: grid; flex: 1; min-width: 0; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.help-field > .help-control { flex: none; margin-top: 1px; }
.help-control { position: relative; display: inline-flex; margin-left: 4px; vertical-align: middle; text-transform: none; }
.help-button { width: 18px; height: 18px; padding: 0; border: 1px solid #9aa8ba; border-radius: 50%; color: #52647b; background: #f7f9fc; cursor: help; font-size: 11px; font-weight: 800; line-height: 16px; }
.help-button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.help-popover { position: absolute; z-index: 20; top: calc(100% + 8px); right: 0; display: none; width: min(310px, calc(100vw - 32px)); padding: 11px 13px; border: 1px solid #cbd4df; border-radius: 8px; color: var(--ink); background: var(--surface); box-shadow: 0 8px 24px rgba(19, 35, 58, .16); font-size: .78rem; font-weight: 400; line-height: 1.4; text-align: left; text-transform: none; white-space: normal; transform: translateX(var(--help-popover-shift, 0)); visibility: hidden; opacity: 0; pointer-events: none; }
.help-field > .help-control { position: static; }
.help-field > .help-control .help-popover { width: min(310px, 100%); }
.help-popover small { display: block; margin-top: 5px; color: var(--muted); font-size: .75rem; }
.help-control .help-popover { display: none; }
.help-control:hover .help-popover, .help-control:focus-within .help-popover, .help-control.is-open .help-popover { display: block; visibility: visible; opacity: 1; pointer-events: auto; }
.help-control.is-dismissed .help-popover { display: none; visibility: hidden; opacity: 0; pointer-events: none; }
.button.danger { color: #fff; background: #a52d2d; }
.logout-form { margin: 0; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: var(--background); }
.login-card { width: min(100%, 430px); padding: 36px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: 0 18px 50px rgba(19, 35, 58, .12); }
.login-card h1 { margin-top: 12px; }
.login-card > .brand-mark { display: inline-grid; place-items: center; }
.login-form { display: grid; gap: 18px; margin-top: 24px; }
.login-form label { display: grid; gap: 7px; color: var(--muted); font-size: .84rem; font-weight: 700; }
.login-form input { min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.login-form input:focus-visible, .login-form button:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.matching-state { display: inline-block; padding: 4px 9px; border-radius: 999px; color: #33465f; background: #e9eef5; font-size: .72rem; font-weight: 800; }
.matching-state.state-allocated { color: #236747; background: #dff3e8; }
.matching-state.state-partially_allocated, .matching-state.state-needs_review { color: #745613; background: #fff0bd; }
.matching-state.state-conflict { color: #842b2b; background: #f9dede; }
.danger-text { display: block; margin-top: 5px; color: #842b2b; }
.matching-fact-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 16px; margin: 0; }
.matching-fact-grid div { min-width: 0; padding: 12px; border-radius: 8px; background: var(--background); }
.matching-fact-grid dt { color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.matching-fact-grid dd { margin: 5px 0 0; overflow-wrap: anywhere; }
.matching-warning { margin-top: 12px; padding: 10px 12px; border-left: 4px solid #d39c24; background: #fffaf0; }
.matching-warning.danger-text { border-left-color: #a52d2d; background: #fff0f0; }
.matching-warning-inline { display: block; margin-bottom: 5px; color: #745613; white-space: normal; }
.matching-layer-blocked { background: #fff5f5; }
.matching-layer-status { display: block; margin-top: 5px; font-size: .75rem; }
.matching-quantity { min-width: 9.5rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.matching-action-form { margin-top: 10px; }
.matching-search { margin-bottom: 18px; }
.sales-matching-page, .sales-matching-page .panel, .matching-command-fields > * { min-width: 0; }
.sales-matching-page .matching-search input, .sales-matching-page .matching-search select { min-height: 44px; }
.sales-matching-page .matching-search input:focus-visible, .sales-matching-page .matching-search select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.sales-matching-page .table-wrap table { min-width: 44rem; }
.sales-matching-page .table-wrap th, .sales-matching-page .table-wrap td { white-space: normal; overflow-wrap: anywhere; }
.matching-confirm-form > .table-wrap table { min-width: 72rem; table-layout: auto; }
.matching-confirm-form > .table-wrap th:nth-child(1) { min-width: 3.5rem; }
.matching-confirm-form > .table-wrap th:nth-child(2) { min-width: 10rem; }
.matching-confirm-form > .table-wrap th:nth-child(3) { min-width: 15rem; }
.matching-confirm-form > .table-wrap th:nth-child(4) { min-width: 17rem; }
.matching-confirm-form > .table-wrap th:nth-child(5) { min-width: 10rem; }
.matching-confirm-form > .table-wrap th:nth-child(6) { min-width: 16rem; }
.matching-confirm-form > .table-wrap td:nth-child(2),
.matching-confirm-form > .table-wrap td:nth-child(5) { overflow-wrap: normal; word-break: normal; }
.sales-matching-page .table-wrap code { white-space: normal; overflow-wrap: anywhere; word-break: break-word; }
.matching-confirm-form { display: grid; gap: 18px; }
.matching-command-fields { display: grid; grid-template-columns: 150px 220px minmax(260px, 1fr) auto; gap: 14px; align-items: end; padding: 18px; border: 1px solid var(--line); border-radius: 9px; background: #f8fafc; }
.matching-command-fields label { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 700; }
.matching-command-fields input, .matching-command-fields select, .matching-command-fields textarea { width: 100%; padding: 9px; border: 1px solid var(--line); border-radius: 6px; background: white; }
.matching-command-fields textarea { min-height: 5rem; resize: vertical; }
.matching-consent { display: flex; gap: 9px; align-items: flex-start; margin: 14px 0; line-height: 1.45; }
.matching-consent input { margin-top: .2rem; }
.link-button { border: 0; padding: 0; color: var(--blue); background: transparent; cursor: pointer; font: inherit; font-weight: 700; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 18px; }
.preview-workspace { scroll-margin-top: 1rem; }
.confirmation-state { margin: 20px 0; padding: 18px 20px; border: 1px solid; border-radius: 10px; }
.confirmation-state h3 { margin: 0 0 8px; }
.confirmation-state p { margin: 0; }
.confirmation-blocked { border-color: #df9d9d; color: #742323; background: #fff2f2; }
.confirmation-ready { border-color: #92c9ac; color: #23583b; background: #effaf4; }
.blocker-list { max-height: 19rem; margin: 14px 0 0; padding-left: 1.4rem; overflow-y: auto; }
.blocker-list > li { margin-top: 12px; }
.blocker-list > li > a { color: inherit; font-weight: 800; }
.blocker-list ul { margin: 6px 0 0; padding-left: 1.2rem; }
.blocker-list ul li { margin-top: 5px; }
.blocker-list span, .row-issues span { display: block; margin-top: 2px; font-weight: 400; }
.allocation-control { margin: 20px 0; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: #f8fafc; }
.allocation-control h3 { margin: 0 0 14px; }
.preview-bulk-actions { margin-top: 22px; }
.preview-reset-actions { margin: 14px 0; }
.preview-reset-actions label { margin-right: 12px; }
.preview-table-compact td { white-space: normal; min-width: 6rem; }
.preview-table-compact td:first-child { min-width: 3.6rem; }
.preview-table-compact td:nth-child(2) { min-width: 12rem; }
.preview-table-compact td:nth-child(8) { min-width: 19rem; }
.preview-table-compact small { display: block; color: var(--muted); }
.preview-row-blocking { background: #fff6f6; box-shadow: inset 4px 0 #b43b3b; scroll-margin-top: 1rem; }
.preview-row-review { background: #fffdf4; }
.row-editor { margin-top: .45rem; min-width: 13rem; }
.row-editor summary, .technical-issue-details summary { cursor: pointer; font-weight: 700; }
.row-editor .mini-form { min-width: 0; margin-top: 10px; }
.review-state { display: inline-block; padding: 3px 8px; border-radius: 999px; font-weight: 800; }
.review-state.is-blocking { color: #842b2b; background: #f9dede; }
.review-state.is-review { color: #745613; background: #fff0bd; }
.review-state.is-ready { color: #236747; background: #dff3e8; }
.row-issues { margin: 10px 0; padding-left: 1.1rem; }
.row-issues li { margin-top: 8px; }
.preview-secondary-data { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 14px; margin: 12px 0; }
.preview-secondary-data div { min-width: 0; }
.preview-secondary-data dt { color: var(--muted); font-size: .7rem; text-transform: uppercase; }
.preview-secondary-data dd { margin: 2px 0 0; overflow-wrap: anywhere; }
.technical-issue-details { margin-top: 10px; }
.technical-issue-details code { display: block; margin-top: 7px; overflow-wrap: anywhere; }
.confirm-import-form { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.confirmation-caption { margin: 0 0 10px; }
.import-success { border-color: #92c9ac; background: #effaf4; }
.import-success h2 { margin-bottom: 8px; }
.import-success .page-actions { align-items: center; margin-top: 16px; }
.order-fact-groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; }
.order-fact-groups section { padding-right: 1rem; border-right: 1px solid var(--line); }
.order-fact-groups section:last-child { border-right: 0; }
.order-fact-groups h3 { margin: 0 0 .75rem; font-size: .95rem; }
.order-fact-groups dl { display: grid; grid-template-columns: minmax(7rem, auto) 1fr; gap: .35rem .7rem; margin: 0; }
.order-fact-groups dt { color: var(--muted); font-weight: 700; }
.order-fact-groups dd { margin: 0; overflow-wrap: anywhere; }
.switch-row { display: flex; align-items: center; gap: 12px; max-width: 520px; }
.switch-row > span:first-child { display: grid; gap: 4px; flex: 1; }
.switch-row small { color: var(--muted); }
.switch-row input { position: absolute; opacity: 0; }
.switch { width: 44px; height: 24px; padding: 3px; border-radius: 20px; background: #9aa8ba; transition: .2s; }
.switch::after { content: ""; display: block; width: 18px; height: 18px; border-radius: 50%; background: white; transition: .2s; }
.switch-row input:checked + .switch { background: var(--blue); }
.switch-row input:checked + .switch::after { transform: translateX(20px); }
.switch-row input:focus-visible + .switch { outline: 2px solid var(--blue); outline-offset: 2px; }
.help-settings { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin: 24px 0; }
.help-settings fieldset { display: grid; align-content: start; gap: 8px; border: 1px solid var(--line); border-radius: 8px; }
.help-settings label { font-size: .84rem; }
.period-fields { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; }
.period-active { margin: 14px 0 0; font-weight: 700; }
.accounting-order-table thead th { position: sticky; top: 0; z-index: 2; background: var(--surface); box-shadow: 0 1px 0 var(--line); }
.dataset-status { display: flex; align-items: center; flex-wrap: wrap; gap: 10px 18px; margin: 0; }
.dataset-status strong { color: #236747; }
.dataset-status.incomplete strong { color: #842b2b; }
.accounting-page, .accounting-page > *, .accounting-page .panel { max-width: 100%; min-width: 0; }
.advanced-sources { margin-top: 20px; }
.advanced-sources summary, .system-details summary { cursor: pointer; font-weight: 700; }
.advanced-sources .import-form { margin-top: 18px; }
.order-link, .page-actions a { color: var(--blue); font-weight: 700; }
.order-search input { min-width: min(420px, 75vw); }
.page-actions { display: flex; gap: 18px; flex-wrap: wrap; }
.button.secondary { border: 1px solid #b9c5d4; color: var(--ink); background: white; }
.export-actions a.button:not(.secondary), .export-actions a.button:not(.secondary):visited, .export-actions a.button:not(.secondary):hover, .export-actions a.button:not(.secondary):focus { color: #fff; background: var(--blue); }
.order-position-heading { align-items: end; margin-bottom: 18px; }
.order-position-heading + .alert { margin-bottom: 18px; }
.variant-toolbar { display: flex; align-items: end; gap: 8px; flex-wrap: nowrap; }
.variant-toolbar label, .settings-form label { display: grid; gap: 6px; color: var(--muted); font-size: .8rem; font-weight: 700; }
.variant-toolbar select, .settings-form select { min-width: 190px; padding: 9px; border: 1px solid var(--line); border-radius: 7px; background: white; }
.variant-toolbar .button { padding: 9px 11px; }
.variant-actions { position: relative; }
.variant-actions > summary { list-style: none; cursor: pointer; white-space: nowrap; }
.variant-actions > summary::-webkit-details-marker { display: none; }
.variant-action-menu { position: absolute; z-index: 12; top: calc(100% + 6px); right: 0; display: grid; gap: 6px; min-width: 230px; padding: 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: 0 8px 24px rgba(19, 35, 58, .16); }
.variant-action-menu .button { width: 100%; text-align: left; }
.view-status { min-height: 1.2em; margin: -10px 0 0; font-size: .8rem; }
.variant-editor { margin: 0 0 20px; padding: 20px; border: 1px solid #cbd4df; border-radius: 9px; background: #f8fafc; }
.editor-heading { display: flex; justify-content: space-between; gap: 16px; }
.editor-heading h3 { margin: 0 0 5px; }
.editor-heading p { margin-bottom: 14px; color: var(--muted); font-size: .83rem; }
.variant-editor fieldset { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 16px; border: 1px solid var(--line); }
.variant-editor legend { font-weight: 700; }
.field-assignment-heading, .field-assignment { display: grid; grid-template-columns: minmax(180px, 1.5fr) repeat(3, minmax(105px, 1fr)) 100px; gap: 10px; align-items: center; padding: 9px; }
.field-assignment-heading { color: var(--muted); font-size: .72rem; font-weight: 700; text-transform: uppercase; }
.field-assignment { border-top: 1px solid var(--line); font-size: .82rem; }
.order-buttons { display: flex; gap: 5px; }
.icon-button { width: 34px; height: 32px; border: 1px solid #b9c5d4; border-radius: 6px; background: white; cursor: pointer; }
.order-position-table th, .order-position-table td { padding: 9px 10px; }
.order-position-table th[data-field="article"], .order-position-table td[data-field="article"] { white-space: normal; min-width: 170px; }
.order-position-table td.wrap { min-width: 220px; }
.details-toggle { border: 0; padding: 4px 7px; color: var(--blue); background: transparent; font-weight: 700; cursor: pointer; }
.position-detail-row td { padding: 0 10px 12px 42px; background: #f8fafc; }
.position-detail-row dl { display: grid; grid-template-columns: repeat(2, minmax(160px, 1fr)); gap: 10px 22px; margin: 0; padding: 14px; border-left: 3px solid #b9cff8; }
.position-detail-row dl div { min-width: 0; }
.position-detail-row dt { color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; }
.position-detail-row dd { margin: 3px 0 0; overflow-wrap: anywhere; white-space: normal; }
.settings-form { display: flex; gap: 20px; flex-wrap: wrap; margin: 18px 0 24px; }
.settings-form label { min-width: 260px; }
.settings-form small { max-width: 330px; font-weight: 400; }
.variant-list { max-width: 700px; padding: 0; list-style: none; }
.variant-list li { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.purchase-shortcuts { display: flex; margin: 0 0 8px; }
#manual-purchase { scroll-margin-top: 88px; }
.purchase-case-confirmed { opacity: .88; }
.purchase-case-confirmed > summary { color: var(--muted); }
.financial-order-breakdown { margin-top: 12px; }

@media (max-width: 1000px) {
    .status-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .purchase-primary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .purchase-primary-grid fieldset:last-child { grid-column: 1 / -1; grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .purchase-disclosure-grid, .purchase-disclosure-grid fieldset:last-child { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .purchase-article-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .matching-fact-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .matching-command-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sales-matching-page .panel-title { align-items: stretch; flex-direction: column; }
    .sales-matching-page .panel-title > form { align-self: flex-start; }
}

@media (max-width: 1280px) {
    .matching-command-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .app-shell { display: block; }
    .sidebar { min-height: auto; padding: 18px; }
    .brand { padding-bottom: 16px; }
    nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .sidebar-footer { display: none; }
    .topbar { height: 60px; padding: 0 20px; }
    .order-position-table thead th { top: 60px; }
    .inventory-compact thead th { top: 60px; }
    [data-inventory-view] > .panel-title { align-items: stretch; flex-direction: column; }
    [data-inventory-view] > .panel-title select { width: 100%; }
    .inventory-compact { table-layout: fixed; }
    .inventory-compact th, .inventory-compact td { padding-right: 8px; padding-left: 8px; }
    .inventory-compact [data-inventory-field="category"],
    .inventory-compact [data-inventory-field="set"],
    .inventory-compact [data-inventory-field="attributes"],
    .inventory-compact [data-inventory-field="unit_cost"],
    .inventory-compact [data-inventory-field="tax"] { display: none; }
    .inventory-compact [data-inventory-field="quantity"] { width: 3.5rem; }
    .inventory-compact th:last-child, .inventory-compact .inventory-actions { width: 5rem; }
    .inventory-mobile-details { display: block; }
    .inventory-detail-content .business-details { grid-template-columns: minmax(0, 1fr); gap: .2rem; }
    .inventory-detail-content .business-details dd { margin: 0 0 .5rem; }
    .inventory-review-form { min-width: 0; }
    .order-fact-groups { grid-template-columns: 1fr; }
    .order-position-heading { align-items: stretch; flex-direction: column; }
    .variant-toolbar { flex-wrap: wrap; }
    .variant-action-menu { right: auto; left: 0; }
    .content { padding: 30px 20px; }
    .panel { padding: 20px; }
    .panel-title { align-items: stretch; flex-direction: column; }
    .panel-title > form { align-self: flex-start; }
    .panel fieldset, .help-settings fieldset, .switch-row, .switch-row > span:first-child { min-width: 0; }
    .help-settings label, .switch-row { overflow-wrap: anywhere; }
    .import-form > label, .import-form > .help-field, .settings-form > label { width: 100%; min-width: 0; }
    .import-form input, .import-form select, .settings-form select { width: 100%; min-width: 0; max-width: 100%; }
    .purchase-working-area, .sales-matching-page { max-width: 100%; }
    .accounting-page { max-width: 100%; }
    .accounting-tax-table { min-width: 70rem; table-layout: auto; }
    .export-actions { align-items: stretch; flex-direction: column; }
    .workspace-grid .form-grid { grid-template-columns: minmax(0, 1fr); }
    .purchase-primary-grid, .purchase-primary-grid fieldset:last-child, .purchase-disclosure-grid, .purchase-disclosure-grid fieldset:last-child, .purchase-article-grid { grid-template-columns: minmax(0, 1fr); }
    .purchase-primary-grid fieldset:last-child, .purchase-article-grid .article-notes { grid-column: auto; }
    .purchase-overview > summary { align-items: flex-start; flex-wrap: wrap; }
    .purchase-overview-preview { flex-basis: calc(100% - 28px); margin-left: 28px; }
    .status-grid { grid-template-columns: 1fr; }
    .welcome-panel { align-items: flex-start; flex-direction: column; }
    .metadata dl { grid-template-columns: 1fr; }
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tax-finalization-fields { grid-template-columns: 1fr; }
    .matching-fact-grid, .matching-command-fields { grid-template-columns: 1fr; }
    .help-settings { grid-template-columns: 1fr; }
    .field-assignment-heading { display: none; }
    .field-assignment { grid-template-columns: 1fr 1fr; }
    .field-assignment strong, .field-assignment .order-buttons { grid-column: 1 / -1; }
    .position-detail-row dl { grid-template-columns: 1fr; }
    .inventory-detail-content { grid-template-columns: 1fr; }
    .inventory-detail-content > .system-details { grid-column: auto; }
    .preview-table-wrap { max-height: none; overflow: visible; }
    .preview-table, .preview-table tbody { display: block; }
    .preview-table thead { display: none; }
    .preview-table tr { display: block; margin-bottom: 14px; border: 1px solid var(--line); border-radius: 9px; overflow: hidden; }
    .preview-table-compact td { display: grid; grid-template-columns: minmax(8rem, .65fr) 1fr; gap: 12px; min-width: 0; border-bottom: 1px solid var(--line); }
    .preview-table-compact td:last-child { border-bottom: 0; }
    .preview-table-compact td::before { content: attr(data-label); color: var(--muted); font-size: .7rem; font-weight: 800; text-transform: uppercase; }
    .preview-table-compact td:nth-child(2), .preview-table-compact td:nth-child(8) { min-width: 0; }
    .preview-secondary-data { grid-template-columns: 1fr; }
}
