:root {
    color-scheme: light;
    --ink: #182126;
    --muted: #5c6970;
    --line: #d7dfe2;
    --surface: #ffffff;
    --canvas: #f4f6f5;
    --sidebar: #202b30;
    --sidebar-hover: #2d3a40;
    --accent: #0a6f68;
    --accent-hover: #075b55;
    --focus: #126fbb;
    --success: #177245;
    --success-bg: #e9f5ee;
    --error: #a43333;
    --error-bg: #faeeee;
    --warning: #7a5810;
    --warning-bg: #fff6dc;
    font-family: "Microsoft JhengHei", "Noto Sans TC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: var(--canvas); }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--canvas); font-size: 15px; line-height: 1.6; }
a { color: inherit; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip-link { position: fixed; top: 8px; left: 8px; z-index: 100; padding: 8px 12px; background: var(--surface); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }
.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; overflow-y: auto; background: var(--sidebar); color: #edf3f4; z-index: 30; }
.sidebar-brand { display: flex; align-items: center; gap: 12px; min-height: 74px; padding: 14px 18px; border-bottom: 1px solid #425057; }
.sidebar-brand strong, .sidebar-brand span { display: block; }
.sidebar-brand span { color: #b8c6ca; font-size: 12px; }
.brand-mark { display: inline-grid; place-items: center; width: 38px; height: 38px; flex: 0 0 38px; border-radius: 6px; background: #dcefed; color: #075b55; font-weight: 800; }
.sidebar-nav { padding: 12px 10px 24px; }
.sidebar-nav ul { margin: 0; padding: 0; list-style: none; }
.sidebar-nav li { margin: 2px 0; }
.sidebar-nav a, .nav-disabled { display: flex; justify-content: space-between; align-items: center; min-height: 42px; padding: 8px 11px; border-radius: 5px; text-decoration: none; }
.sidebar-nav a:hover, .sidebar-nav a.active { background: var(--sidebar-hover); }
.sidebar-nav a.active { box-shadow: inset 3px 0 #69bdb5; }
.sidebar-nav .nav-children { margin: 2px 0 8px 14px; border-left: 1px solid #526168; }
.sidebar-nav .nav-children a { min-height: 34px; padding: 5px 10px; color: #cbd6d9; font-size: 13px; }
.nav-disabled { color: #aebbc0; cursor: not-allowed; }
.nav-disabled small { font-size: 11px; color: #88979d; }
.app-column { min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; justify-content: space-between; align-items: center; min-height: 64px; padding: 8px 24px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar-start, .topbar-user { display: flex; align-items: center; gap: 14px; }
.system-name { font-weight: 700; }
.user-summary { text-align: right; line-height: 1.3; }
.user-summary strong, .user-summary span { display: block; }
.user-summary span { color: var(--muted); font-size: 12px; }
.icon-button { display: inline-grid; place-items: center; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); cursor: pointer; }
.menu-toggle { display: none; }
.main-content { width: min(1440px, 100%); padding: 28px clamp(18px, 3vw, 44px) 56px; }
.page-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; margin-bottom: 28px; }
.page-header h1, .auth-heading h1 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.25; letter-spacing: 0; }
.page-header p { margin: 7px 0 0; color: var(--muted); }
.eyebrow { margin: 0 0 5px !important; color: var(--accent) !important; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 32px; }
.metric-card, .module-card { border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.metric-card { min-height: 112px; padding: 18px; }
.metric-card span { display: block; color: var(--muted); }
.metric-card strong { display: block; margin-top: 10px; font-size: 24px; }
.page-section { margin-top: 30px; }
.section-heading { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 12px; }
.section-heading h2, .filter-section h2, .detail-section h2, .data-columns h2 { margin: 0; font-size: 18px; }
.section-heading span { color: var(--muted); font-size: 13px; }
.module-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.module-card { min-height: 108px; padding: 16px; }
.module-card h3 { margin: 0 0 18px; font-size: 16px; }
.status-label { display: inline-block; padding: 2px 7px; border-radius: 4px; background: #edf0f1; color: var(--muted); font-size: 12px; font-weight: 700; }
.status-success { background: var(--success-bg); color: var(--success); }
.status-error { background: var(--error-bg); color: var(--error); }
.status-warning { background: var(--warning-bg); color: var(--warning); }
.button { display: inline-flex; justify-content: center; align-items: center; min-height: 38px; padding: 7px 14px; border: 1px solid transparent; border-radius: 5px; text-decoration: none; cursor: pointer; font-weight: 700; }
.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover { background: var(--accent-hover); }
.button-secondary { color: var(--ink); background: var(--surface); border-color: var(--line); }
.button-block { width: 100%; }
.text-link, .table-link { color: var(--accent); font-weight: 700; text-decoration: none; }
.text-link:hover, .table-link:hover { text-decoration: underline; }
.message-list { display: grid; gap: 8px; margin-bottom: 18px; }
.message { padding: 10px 13px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.message-success { color: var(--success); border-color: #acd2bb; background: var(--success-bg); }
.message-error { color: var(--error); border-color: #e4b5b5; background: var(--error-bg); }
.message-warning { color: var(--warning); border-color: #e5cd8c; background: var(--warning-bg); }
.auth-body { display: grid; min-height: 100vh; background: #eef2f1; }
.auth-main { display: grid; place-items: center; width: 100%; padding: 28px 18px; }
.auth-panel { width: min(440px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); box-shadow: 0 12px 28px rgba(24, 33, 38, .08); }
.auth-heading { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.auth-heading p { margin: 0 0 2px; color: var(--muted); font-size: 13px; }
.auth-heading h1 { font-size: 23px; }
.form-stack { display: grid; gap: 18px; }
.field-group { min-width: 0; }
.field-group label { display: block; margin-bottom: 5px; font-weight: 700; }
.field-group input, .field-group select, .field-group textarea { width: 100%; min-height: 40px; padding: 8px 10px; border: 1px solid #b7c2c6; border-radius: 5px; background: var(--surface); color: var(--ink); }
.field-group input:focus, .field-group select:focus, .field-group textarea:focus { border-color: var(--focus); outline: 2px solid rgba(18, 111, 187, .18); }
.errorlist { margin: 5px 0 0; padding-left: 20px; color: var(--error); }
.form-errors { padding: 10px; border: 1px solid #e4b5b5; border-radius: 5px; color: var(--error); background: var(--error-bg); }
.form-errors .errorlist { margin: 0; }
.field-help { margin-top: 5px; color: var(--muted); font-size: 13px; }
.field-help ul { padding-left: 20px; }
.product-search-control { position: relative; }
.product-search-results { position: absolute; z-index: 15; top: calc(100% + 4px); left: 0; right: 0; max-height: 340px; overflow-y: auto; border: 1px solid #9ba9ae; border-radius: 5px; background: var(--surface); box-shadow: 0 10px 24px rgba(24, 33, 38, .14); }
.quick-product-search-results { z-index: 60; min-width: 100%; }
.product-search-option { display: grid; width: 100%; grid-template-columns: minmax(0, 1fr) auto; gap: 3px 14px; padding: 10px 12px; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.product-search-option:last-child { border-bottom: 0; }
.product-search-option:hover, .product-search-option.is-active { background: #eaf3f2; }
.product-search-option:disabled { cursor: not-allowed; opacity: .68; background: #f2f4f4; }
.product-search-option strong, .product-search-option span { min-width: 0; overflow-wrap: anywhere; }
.product-search-option-meta { color: var(--muted); font-size: 13px; }
.product-search-option-status { align-self: center; grid-row: 1 / span 2; grid-column: 2; }
.product-search-empty { padding: 13px; color: var(--muted); }
.selected-product-summary { padding: 14px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.selected-product-summary .section-heading { margin-bottom: 10px; }
.selected-product-summary .section-heading span { color: var(--error); font-weight: 700; }
.selected-product-summary dl { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.selected-product-summary dt { color: var(--muted); font-size: 12px; }
.selected-product-summary dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.count-batch-panel { margin-top: 28px; padding-top: 22px; border-top: 1px solid var(--line); }
.count-batch-preview { margin-top: 18px; }
.count-workspace-table { min-width: 980px; }
.count-workspace-table .count-item-form { display: block; min-width: 88px; }
.count-workspace-table .count-item-form input[type="number"],
.count-workspace-table input[data-count-item-note] { width: 100%; min-height: 40px; padding: 7px 9px; border: 1px solid #b7c2c6; border-radius: 5px; }
.count-workspace-table td { vertical-align: top; }
.count-product-cell { min-width: 250px; white-space: normal; }
.count-product-sku, .count-product-name, .count-product-category { display: block; overflow-wrap: anywhere; }
.count-product-sku { color: var(--muted); font-size: 12px; font-weight: 700; }
.count-product-name { margin-top: 3px; font-size: 15px; line-height: 1.4; }
.count-product-category { margin-top: 4px; color: var(--muted); font-size: 12px; }
.count-info-cell { min-width: 130px; white-space: normal; }
.count-info-cell span { display: block; }
.count-info-cell span + span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.count-note-cell { min-width: 14em; white-space: normal; }
.count-row-message { display: block; min-height: 1.4em; margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.35; }
[data-save-state="saved"] .count-row-message { color: var(--success); }
[data-save-state="error"] .count-row-message,
[data-save-state="conflict"] .count-row-message { color: var(--error); }
.count-operation-cell { white-space: nowrap; }
.count-sync-status { color: var(--muted); }
.metric-card strong [data-summary-field] { display: inline; color: inherit; }
.adjustment-preview { padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: #f7f9f9; }
.adjustment-preview h2 { margin: 0 0 12px; font-size: 17px; }
.adjustment-preview dl { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 18px; margin: 0; }
.adjustment-preview dl div { min-width: 0; }
.adjustment-preview dt { color: var(--muted); font-size: 12px; }
.adjustment-preview dd { margin: 3px 0 0; font-weight: 700; overflow-wrap: anywhere; }
.form-actions, .filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.narrow-section { max-width: 680px; }
.form-section, .filter-section { padding: 20px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.filter-section h2 { margin-bottom: 14px; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; white-space: nowrap; }
th { background: #edf1f1; color: #3c494f; font-size: 13px; }
tbody tr:last-child td { border-bottom: 0; }
.product-list-table { table-layout: fixed; }
.product-list-table col.product-col-product { width: 32%; }
.product-list-table col.product-col-category { width: 11%; }
.product-list-table col.product-col-stock { width: 9%; }
.product-list-table col.product-col-transit { width: 8%; }
.product-list-table col.product-col-suggested { width: 9%; }
.product-list-table col.product-col-cost { width: 11%; }
.product-list-table col.product-col-status { width: 12%; }
.product-list-table col.product-col-action { width: 8%; }
.product-list-table th, .product-list-table td { padding: 9px 10px; vertical-align: middle; white-space: normal; }
.product-list-product { min-width: 0; }
.product-list-sku { display: block; white-space: nowrap; }
.product-list-name { display: -webkit-box; margin-top: 2px; overflow: hidden; color: var(--ink); font-size: 15px; font-weight: 400; line-height: 1.35; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.product-list-stack { display: grid; gap: 1px; line-height: 1.4; }
.product-list-stack span { white-space: nowrap; }
.product-list-stack small { color: var(--muted); font-size: 12px; }
.product-list-update { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; white-space: nowrap; }
.product-list-actions { white-space: nowrap; }
.empty-state { padding: 24px; color: var(--muted); text-align: center; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; color: var(--muted); }
.pagination-actions { display: flex; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.detail-grid div { min-width: 0; padding: 14px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.detail-grid span, .detail-grid strong { display: block; }
.detail-grid span { color: var(--muted); font-size: 12px; }
.break-text { overflow-wrap: anywhere; }
.detail-section { padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.data-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.data-columns > div { min-width: 0; padding: 18px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
pre { max-height: 420px; overflow: auto; padding: 12px; border-radius: 5px; background: #20292d; color: #eef5f5; white-space: pre-wrap; overflow-wrap: anywhere; }
.result-section, .error-page { width: min(640px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.error-page { text-align: center; }
.error-code { margin: 0; color: var(--accent); font-size: 48px; font-weight: 800; }
.sidebar-backdrop { display: none; }
.settings-card { display: flex; min-height: 136px; flex-direction: column; justify-content: space-between; }
.settings-card h2 { margin: 0; font-size: 17px; }
.settings-card p { margin: 6px 0 18px; color: var(--muted); }
.card-actions, .row-actions { display: flex; align-items: center; gap: 9px; }
.row-actions form { margin: 0; }
.disabled-action { color: var(--muted); cursor: not-allowed; text-decoration: none; }
.order-list-compact { min-width: 940px; }
.order-list-compact th, .order-list-compact td { vertical-align: middle; }
.order-list-compact th:nth-child(4), .order-list-compact td:nth-child(4) { max-width: 150px; }
.order-list-actions { white-space: nowrap; }
.order-list-actions .table-link { display: inline-block; margin-right: 7px; }
.link-button { padding: 0; border: 0; color: var(--accent); background: transparent; cursor: pointer; font-weight: 700; }
.link-button:hover { text-decoration: underline; }
.checkbox-label { display: flex !important; align-items: center; gap: 8px; }
.checkbox-label input { width: 18px !important; min-height: 18px !important; }
.page-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.page-actions form { margin: 0; }
.dense-table th, .dense-table td { padding: 8px 9px; font-size: 13px; }
.wrap-cell { max-width: 220px; white-space: normal; overflow-wrap: anywhere; }
.shipment-tail { display: inline-block; min-width: 48px; padding: 2px 6px; border: 1px solid #879399; text-align: center; letter-spacing: 1px; }
.print-selection-heading { align-items: center; }
.print-selection-heading > div:first-child span { display: block; }
.print-queue-table input[type="checkbox"] { width: 18px; height: 18px; }
.notice-banner { padding: 12px 16px; border: 1px solid #d6bd72; border-radius: 6px; color: #6a5316; background: #fff8df; }
.return-item-form-cell { min-width: 720px; }
.return-item-form { display: grid; grid-template-columns: 82px 100px 70px 150px minmax(170px, 1fr) auto; align-items: center; gap: 8px; }
.return-item-form input, .return-item-form select { width: 100%; min-height: 34px; padding: 5px 7px; }
.return-item-form output { font-weight: 800; text-align: right; }
.return-items-table input, .return-items-table select { min-width: 92px; min-height: 34px; padding: 5px 7px; border: 1px solid #b7c2c6; border-radius: 5px; }
.return-items-table input[name$="item_reason"] { min-width: 180px; }
.return-items-table output { font-weight: 800; }
.return-record-items { display: grid; gap: 3px; min-width: 220px; white-space: normal; }
.muted-text { color: var(--muted); font-size: 12px; }
.order-workspace { display: grid; gap: 14px; }
.draft-workspace-bar { padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 5px 14px rgba(24, 33, 38, .07); }
.draft-workspace-heading { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-bottom: 5px; }
.draft-workspace-heading form { margin: 0; }
.draft-workspace-heading .eyebrow { margin-bottom: 1px !important; }
.draft-workspace-heading h1 { margin: 0; font-size: 19px; line-height: 1.15; }
.draft-list { border-top: 1px solid var(--line); }
.draft-list-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; min-height: 43px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.draft-list-row:last-child { border-bottom: 0; }
.draft-list-row:hover { background: #f2f7f6; }
.draft-list-row.is-active { background: #eaf3f2; box-shadow: inset 4px 0 var(--accent); }
.draft-row-main { display: flex; flex: 1 1 auto; align-items: center; flex-wrap: wrap; gap: 7px; min-width: 0; color: var(--ink); text-decoration: none; }
.draft-row-main span { min-width: 0; }
.draft-sequence { flex: 0 0 auto; color: var(--accent); font-weight: 800; }
.draft-value-badge { display: inline-flex; align-items: center; max-width: 180px; min-height: 26px; overflow: hidden; padding: 2px 8px; border: 1px solid transparent; border-radius: 4px; font-size: 12px; font-weight: 700; line-height: 1.3; text-overflow: ellipsis; white-space: nowrap; }
.draft-platform-badge { color: #205a6b; border-color: #bfd9df; background: #eaf4f6; }
.draft-shipping-badge { color: #555f27; border-color: #d3d9ae; background: #f3f5e7; }
.draft-recipient-badge { color: #6a5316; border-color: #e3d39d; background: #fff8df; }
.draft-total-badge { color: #60426c; border-color: #d8c8df; background: #f4eef6; font-variant-numeric: tabular-nums; }
.draft-save-state { color: var(--muted); font-size: 12px; font-weight: 700; white-space: nowrap; }
.draft-save-state.status-saved { color: var(--success); }
.draft-save-state.status-insufficient_stock, .draft-save-state.status-system_error, .draft-save-state.status-save_failed { color: var(--error); }
.draft-save-state.status-incomplete, .draft-save-state.status-validation_error { color: var(--warning); }
.draft-row-actions { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 7px; margin-left: auto; }
.draft-row-actions form { margin: 0; }
.button-danger { color: var(--error); border-color: #dfb9b9; }
.button-danger:hover { background: var(--error-bg); }
.workspace-empty { display: grid; place-items: center; gap: 3px; min-height: 118px; color: var(--muted); text-align: center; }
.workspace-empty strong { color: var(--ink); font-size: 17px; }
.active-order-editor { display: grid; gap: 14px; }
.draft-list > .active-order-editor { padding: 12px; border-bottom: 1px solid var(--line); background: #fbfdfd; }
.draft-list > .active-order-editor[hidden] { display: none; }
.order-editor-header { display: flex; justify-content: space-between; align-items: center; gap: 20px; min-height: 44px; padding: 0 2px; }
.order-editor-title { display: flex; align-items: center; gap: 10px; }
.order-editor-title h2 { margin: 0; font-size: 20px; }
.order-editor-footer { display: flex; justify-content: flex-end; padding-top: 2px; }
.order-form-compact { padding: 10px 12px; }
.order-form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 10px; }
.order-finance-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 5px 10px; }
.order-form-compact .field-group label, .order-form-compact .field-label { margin-bottom: 1px; font-size: 11px; line-height: 1.35; }
.order-form-compact .field-group input, .order-form-compact .field-group select, .order-form-compact .field-group textarea { min-height: 30px; padding: 3px 7px; }
.order-form-compact .field-group textarea { height: 34px; min-height: 30px; resize: vertical; }
.field-span-2 { grid-column: 1 / -1; }
.order-form-grid .field-span-2 { grid-column: span 2; }
.field-span-3 { grid-column: 1 / -1; }
.field-checkbox { display: flex; flex-direction: column; justify-content: flex-end; }
.field-checkbox .checkbox-label { min-height: 30px; margin: 0; }
.invoice-inline-controls { display: flex; align-items: center; flex-wrap: nowrap; gap: 8px; min-height: 30px; }
.invoice-inline-controls .checkbox-label { flex: 0 0 auto; }
.invoice-tax-inline { display: flex; flex: 1 1 auto; align-items: center; gap: 8px; min-width: 0; }
.invoice-tax-inline[hidden] { display: none; }
.invoice-tax-inline label { margin: 0; white-space: nowrap; }
.invoice-tax-inline input { width: min(150px, 100%); min-width: 90px; }
.field-errors:empty { display: none; }
.order-product-section, .order-items-section { margin-top: 2px; }
.order-product-section { display: grid; grid-template-columns: 210px minmax(0, 760px); align-items: end; gap: 14px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.order-product-section .section-heading { display: block; margin: 0 0 3px; }
.order-items-section .section-heading { margin-bottom: 5px; }
.order-product-section .section-heading h2 { font-size: 16px; }
.order-product-section .section-heading span { display: block; }
.order-product-section .field-group { max-width: 760px; }
.order-product-section .field-group label { margin-bottom: 1px; font-size: 11px; }
.order-product-section .field-group input { min-height: 31px; padding: 3px 7px; }
.order-product-section .field-help { margin-top: 1px; font-size: 11px; }
.order-items-table th, .order-items-table td { padding: 5px 8px; vertical-align: middle; }
.order-items-table td input { width: 92px; min-height: 29px; padding: 3px 7px; border: 1px solid #b7c2c6; border-radius: 5px; }
.order-items-table td:nth-child(2) { max-width: 260px; white-space: normal; }
.numeric-cell { text-align: right; }
.button-compact { min-height: 32px; padding: 4px 9px; font-size: 13px; }
.locked-cost { color: var(--muted); text-align: right; }
.order-checkout-bar { display: grid; grid-template-columns: minmax(130px, .7fr) repeat(3, minmax(110px, .55fr)); align-items: end; gap: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); box-shadow: 0 -3px 12px rgba(24, 33, 38, .05); }
.order-discount-field { padding-right: 14px; }
.order-discount-field label { margin-bottom: 3px; font-size: 12px; }
.order-discount-field input { min-height: 36px; }
.checkout-metric { min-height: 48px; padding: 3px 12px; border-left: 1px solid var(--line); }
.checkout-metric span, .checkout-metric strong { display: block; }
.checkout-metric span { color: var(--muted); font-size: 12px; }
.checkout-metric strong { margin-top: 2px; font-size: 17px; }
.checkout-total strong { color: var(--accent); font-size: 21px; }
.batch-submit-section { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 16px 18px; border: 1px solid #b9d3d0; border-radius: 6px; background: #f7fbfa; }
.batch-submit-content { min-width: 0; }
.batch-submit-content h2 { margin: 0; font-size: 18px; }
.batch-submit-content p { margin: 4px 0 2px; color: var(--ink); }
.batch-submit-content small { display: block; color: var(--muted); }
.batch-submit-section form { flex: 0 0 auto; margin: 0; text-align: right; }
.batch-submit-section .field-help { max-width: 240px; margin-top: 4px; }
.batch-result { padding: 12px 14px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.batch-result .section-heading { margin-bottom: 8px; }
.batch-result-group + .batch-result-group { margin-top: 9px; }
.batch-result-group h3 { margin: 0 0 4px; font-size: 14px; }
.batch-result-group ul { display: grid; gap: 3px; margin: 0; padding: 0; list-style: none; }
.batch-result-group li { display: flex; gap: 10px; justify-content: space-between; padding: 4px 8px; border-radius: 4px; font-size: 13px; }
.batch-result-group li span { overflow-wrap: anywhere; text-align: right; }
.batch-result-success li { background: var(--success-bg); }
.batch-result-retained li { background: var(--warning-bg); }
.order-totals { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.order-totals div { padding: 16px; border-right: 1px solid var(--line); }
.order-totals div:last-child { border-right: 0; }
.order-totals span, .order-totals strong { display: block; }
.order-totals span { color: var(--muted); font-size: 13px; }
.order-totals strong { margin-top: 5px; font-size: 20px; }
.confirmation-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 20px; margin: 0 0 24px; }
.confirmation-summary div { padding-bottom: 9px; border-bottom: 1px solid var(--line); }
.confirmation-summary dt { color: var(--muted); font-size: 13px; }
.confirmation-summary dd { margin: 3px 0 0; font-size: 18px; font-weight: 700; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.form-grid .form-actions { grid-column: 1 / -1; }

@media (max-width: 1200px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .draft-value-badge { max-width: 150px; }
    .order-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .field-span-3 { grid-column: 1 / -1; }
    .order-checkout-bar { grid-template-columns: repeat(4, minmax(110px, 1fr)); }
}

@media (max-width: 1100px) {
    .count-workspace-table { min-width: 0; }
    .count-workspace-table thead { display: none; }
    .count-workspace-table tbody { display: block; }
    .count-workspace-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 10px; border-bottom: 1px solid var(--line); }
    .count-workspace-table tbody tr:last-child { border-bottom: 0; }
    .count-workspace-table td { display: block; min-width: 0; padding: 8px; border: 0; white-space: normal; }
    .count-workspace-table td::before { display: block; margin-bottom: 4px; color: var(--muted); content: attr(data-label); font-size: 11px; font-weight: 700; }
    .count-workspace-table .count-product-cell,
    .count-workspace-table .count-note-cell,
    .count-workspace-table .count-operation-cell { grid-column: 1 / -1; }
    .count-workspace-table .empty-state { grid-column: 1 / -1; }
    .count-workspace-table .count-item-form { min-width: 0; }
    .count-workspace-table input[data-count-item-note] { min-width: 12em; }
    .count-operation-cell { display: flex; align-items: center; justify-content: flex-end; }
}

@media (max-width: 760px) {
    .app-shell { display: block; }
    .sidebar { position: fixed; left: 0; transform: translateX(-100%); width: min(290px, 86vw); transition: transform .2s ease; }
    .sidebar-open .sidebar { transform: translateX(0); }
    .sidebar-backdrop { position: fixed; inset: 0; z-index: 25; width: 100%; height: 100%; border: 0; background: rgba(16, 24, 28, .45); }
    .sidebar-open .sidebar-backdrop { display: block; }
    .menu-toggle { display: inline-grid; }
    .topbar { padding: 8px 14px; }
    .system-name, .user-summary span, .topbar .text-link { display: none; }
    .main-content { padding: 22px 14px 42px; }
    .page-header { display: block; }
    .page-header > .button { margin-top: 12px; }
    .module-grid, .data-columns { grid-template-columns: 1fr; }
    .filter-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .selected-product-summary dl { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .draft-workspace-heading, .order-editor-header { align-items: stretch; flex-direction: column; }
    .draft-list-row { align-items: center; flex-wrap: wrap; }
    .draft-row-main { flex-wrap: wrap; }
    .draft-row-actions { margin-left: auto; }
    .order-form-grid { grid-template-columns: 1fr; }
    .order-finance-row { grid-template-columns: 1fr; }
    .order-form-grid .field-span-2, .field-span-3 { grid-column: auto; }
    .invoice-inline-controls { align-items: flex-start; flex-direction: column; }
    .order-product-section { grid-template-columns: 1fr; }
    .order-checkout-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .checkout-metric { border-left: 0; border-top: 1px solid var(--line); }
    .batch-submit-section { align-items: stretch; flex-direction: column; gap: 12px; }
    .batch-submit-section form { text-align: left; }
    .batch-result-group li { align-items: flex-start; flex-direction: column; gap: 1px; }
    .batch-result-group li span { text-align: left; }
    .order-totals { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pagination { align-items: flex-start; gap: 10px; flex-direction: column; }
    .product-list-table { min-width: 820px; }
}

@media (max-width: 480px) {
    .metric-grid, .detail-grid { grid-template-columns: 1fr; }
    .adjustment-preview dl { grid-template-columns: 1fr; }
    .selected-product-summary dl { grid-template-columns: 1fr; }
    .topbar-user { gap: 8px; }
    .user-summary { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .auth-panel { padding: 22px 18px; }
    .order-checkout-bar { grid-template-columns: 1fr; }
    .batch-submit-section .button { width: 100%; }
    .order-totals, .confirmation-summary { grid-template-columns: 1fr; }
    .order-totals div { border-right: 0; border-bottom: 1px solid var(--line); }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
/* Phase 6C-1 smart purchase analysis */
.checkbox-grid ul {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: .5rem 1rem;
    padding: 0;
    list-style: none;
}

.checkbox-stack,
.compact-form {
    display: grid;
    gap: .45rem;
}

.compact-form {
    min-width: 150px;
}

.compact-form label {
    display: grid;
    gap: .2rem;
    font-size: .78rem;
}

.compact-form input[type="number"],
.compact-form input:not([type]) {
    min-width: 7rem;
}

.analysis-table {
    min-width: 1500px;
}

.analysis-table th {
    white-space: nowrap;
}

.notice-card {
    border-left: 4px solid var(--color-primary, #1f5c72);
}

.shopee-manual-product {
    margin-top: .65rem;
    max-width: 560px;
    position: relative;
}

.shopee-manual-product input[type="search"] {
    width: 100%;
}

.status-label.status-manual-resolution {
    background: #fde8e8;
    color: #9b1c1c;
}

.shopee-manual-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    justify-content: flex-start;
    margin-bottom: .55rem;
}

.shopee-product-dropdown {
    background: var(--surface, #fff);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    display: grid;
    margin-top: .25rem;
    max-height: 360px;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    z-index: 20;
}

.shopee-product-option {
    align-items: start;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    display: grid;
    gap: .15rem;
    grid-template-columns: 1fr auto;
    padding: .65rem .75rem;
    text-align: left;
    width: 100%;
}

.shopee-product-option strong,
.shopee-product-option span,
.shopee-product-option small {
    grid-column: 1;
    overflow-wrap: anywhere;
}

.shopee-product-option b {
    align-self: center;
    grid-column: 2;
    grid-row: 1 / span 3;
}

.shopee-product-option:hover,
.shopee-product-option:focus-visible {
    background: var(--surface-muted, #f3f7f8);
    outline: 0;
}

.shipment-number-controls {
    align-items: center;
    display: flex;
    flex-wrap: wrap;
    gap: .45rem;
}

.shipment-number-controls input {
    flex: 1 1 220px;
    min-width: 0;
}

.shipment-number-controls .button {
    flex: 0 0 auto;
}
