/* Khung làm việc và các thành phần danh sách dùng chung. */
:root {
  --ink: #20242b;
  --muted: #687483;
  --line: #dbe1e8;
  --canvas: #edf1f6;
  --primary: #2282d5;
  --primary-dark: #176cbd;
  --shadow: none;
}

body { background: var(--canvas); }
.app-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); grid-template-rows: 60px minmax(calc(100vh - 60px), auto); align-items: start; }
.workspace { display: contents; }
.topbar { grid-column: 1 / -1; grid-row: 1; position: sticky; top: 0; z-index: 30; height: 60px; padding: 0 16px; background: #1b62b5; border: 0; color: #fff; }
.topbar-start { gap: 12px; }
.sidebar-collapse-toggle { width: 29px; min-height: 34px; border: 0; background: transparent; color: #fff; font-size: 21px; }
.sidebar-collapse-toggle:hover, .topbar-action:hover { background: #ffffff20; color: #fff; border-color: transparent; }
.topbar .brand-row, .app-layout.is-sidebar-collapsed .topbar .brand-row { display: flex; gap: 10px; width: auto; height: auto; min-height: 0; margin: 0; padding: 0; background: transparent; color: #fff; }
.topbar .brand-mark { width: 38px; height: 36px; border-radius: 5px; background: #fff; color: #167bc7; box-shadow: none; font-size: 19px; }
.topbar .brand-row strong { max-width: min(30vw, 270px); overflow: hidden; color: #fff; font-size: calc(19px * var(--ui-text-scale, 1)); font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.breadcrumbs { display: none; }
.topbar-actions { gap: 12px; }
.topbar-action { min-height: 36px; border: 0; background: transparent; color: #fff; font-size: calc(14px * var(--ui-text-scale, 1)); }
.text-size-picker { color: #fff; font-size: calc(13px * var(--ui-text-scale, 1)); }
.text-size-picker select { height: 32px; border-color: #ffffff80; border-radius: 5px; font-size: calc(12px * var(--ui-text-scale, 1)); }
.topbar-user { position: relative; color: #fff; }
.topbar-user summary { display: flex; align-items: center; gap: 7px; cursor: pointer; list-style: none; }
.topbar-user summary::-webkit-details-marker { display: none; }
.topbar-user summary::after { content: '⌄'; }
.topbar-user .avatar { width: 27px; height: 27px; border: 1px solid #fff; background: transparent; color: #fff; font-size: 12px; }
.topbar-user .user-copy strong { color: #fff; font-size: calc(13px * var(--ui-text-scale, 1)); }
.topbar-user .user-copy span { display: none; }
.user-menu { position: absolute; right: 0; top: calc(100% + 10px); min-width: 150px; padding: 5px; border: 1px solid #dce3ec; border-radius: 6px; background: #fff; box-shadow: 0 5px 20px #1b304022; }
.user-menu .logout-button { width: 100%; padding: 9px; color: #273645; }
.user-menu .logout-button:hover { background: #eef5fc; color: #176cbd; }
.quick-actions { display: none; }

.sidebar { grid-column: 1; grid-row: 2; position: sticky; top: 60px; width: 250px; height: calc(100vh - 60px); overflow-y: auto; padding: 10px 10px 14px; background: #fff; border-right: 1px solid #dce1e8; color: #24649e; }
.nav-caption { display: none; }
.main-navigation { display: flex; align-items: stretch; gap: 2px; }
.nav-item { --nav-color: #1c75bf; display: flex; width: 100%; min-height: 43px; justify-content: flex-start; gap: 12px; padding: 0 15px; border: 0; border-radius: 7px; background: transparent; color: var(--nav-color); font-size: calc(14px * var(--ui-text-scale, 1)); font-weight: 600; text-align: left; }
.nav-item:hover { background: #edf5fc; color: var(--nav-color); }
.nav-item.is-active { background: var(--nav-color); color: #fff; box-shadow: none; }
.nav-item[data-page="purchases"], .nav-item[data-page="suppliers"] { --nav-color: #5b4bcd; }
.nav-item[data-page="sales"], .nav-item[data-page="debt"] { --nav-color: #0e95a4; }
.nav-item[data-page="quotations"], .nav-item[data-page="customers"] { --nav-color: #aa39bd; }
.nav-item[data-page="inventory"] { --nav-color: #0ba77c; }
.nav-item[data-page="cash"] { --nav-color: #32b44a; }
.nav-item[data-page="reports"] { --nav-color: #f46a00; }
.nav-item[data-page="settings"], .nav-item[data-page="print-settings"], .nav-item[data-page="users"] { --nav-color: #454e57; }
.nav-item[data-page="bots"] { --nav-color: #168e77; }
.nav-icon { display: block; width: 19px; height: 19px; flex: 0 0 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; color: inherit; }
.sidebar-bottom { width: 100%; margin-top: auto; padding: 14px 8px 0; border-color: #e1e5eb; }
.sidebar-note { color: #61788a; font-size: 12px; }
.app-layout.is-sidebar-collapsed { grid-template-columns: 66px minmax(0, 1fr); }
.app-layout.is-sidebar-collapsed .sidebar { width: 66px; padding: 10px 9px; }
.app-layout.is-sidebar-collapsed .main-navigation { width: 100%; }
.app-layout.is-sidebar-collapsed .nav-item { width: 46px; justify-content: center; padding: 0; }
.app-layout.is-sidebar-collapsed .nav-item > span:last-child, .app-layout.is-sidebar-collapsed .sidebar-note { display: none; }

.page-content, .is-sales-entry .page-content { grid-column: 2; grid-row: 2; width: 100%; max-width: none; min-width: 0; margin: 0; padding: 16px 16px 32px; }
.page-heading { align-items: center; gap: 12px; margin: 0 0 14px; }
.page-heading h1, .report-detail-heading h1 { margin: 0; color: #171b20; font-size: calc(21px * var(--ui-text-scale, 1)); font-weight: 700; letter-spacing: 0; }
.page-heading .eyebrow, .page-heading .muted { display: none; }
.page-actions, .cash-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cash-actions { margin: 0 0 12px; }
.button { min-height: 38px; padding: 0 13px; border-radius: 6px; font-size: calc(13px * var(--ui-text-scale, 1)); font-weight: 600; }
.button-secondary { border-color: #cfd6df; background: #fff; color: #222a32; }
.button-secondary:hover { border-color: #8cbce2; background: #eef7ff; color: #1766a8; }
.content-card { border-color: #dce1e7; border-radius: 7px; box-shadow: none; }
.table-card { overflow: visible; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.table-card .table-toolbar { min-height: 0; padding: 0; margin-bottom: 10px; border: 0; }
.table-toolbar.list-toolbar { justify-content: flex-start; }
.list-filters { align-items: end; }
.search-field { width: min(100%, 330px); border: 1px solid #c9d0d8; border-radius: 6px; background: #fff; }
.search-field input { height: 38px; font-size: calc(13px * var(--ui-text-scale, 1)); }
.list-filters > label, .report-filters > label { color: #404850; font-size: calc(12px * var(--ui-text-scale, 1)); }
.list-filters input, .list-filters select, .product-toolbar select, .report-filters input, .report-filters select { height: 38px; border-color: #c9d0d8; border-radius: 6px; font-size: calc(13px * var(--ui-text-scale, 1)); }
.list-filters > .search-field { flex-direction: row; align-items: center; }
.list-filters > .search-field input { border: 0; background: transparent; padding: 0; }
.party-toolbar { justify-content: flex-start; }
.party-count-wrap { color: #171b20; }
.party-debt-filter input { appearance: none; position: relative; width: 40px; height: 22px; flex: 0 0 40px; margin: 0; border: 0; border-radius: 999px; background: #d8dee5; cursor: pointer; }
.party-debt-filter input::before { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: transform .15s ease; }
.party-debt-filter input:checked { background: #2282d5; }
.party-debt-filter input:checked::before { transform: translateX(18px); }
.party-debt-filter input:focus-visible { outline: 2px solid #176cbd; outline-offset: 2px; }
.data-table td.party-owing { color: #e03940; }
.date-range-presets { gap: 4px; padding: 0 0 10px; }
.date-range-preset { min-height: 30px; padding: 0 10px; border: 0; border-radius: 5px; background: #d5ebfd; color: #1f669f; font-size: calc(12px * var(--ui-text-scale, 1)); }
.date-range-preset.is-active { background: #fff; color: #26394c; box-shadow: 0 1px 3px #1f34401a; }
.data-table { min-width: 760px; border-collapse: collapse; }
.data-table th { padding: 10px 11px; border: 1px solid #d3e0ec; background: #e2edf9; color: #174b79; font-size: calc(13px * var(--ui-text-scale, 1)); font-weight: 700; text-transform: none; }
.data-table td { padding: 10px 11px; border-top: 1px solid #dfe4e9; color: #292f35; font-size: calc(13px * var(--ui-text-scale, 1)); }
.data-table td strong { color: #222a32; font-weight: 600; }
.data-table tbody tr:nth-child(odd) td { background: #f9fafb; }
.data-table tbody tr:nth-child(even) td { background: #edf1f6; }
.selectable-row:hover td, .selectable-row:focus td { background: #dcecfb !important; }
.selectable-row.is-selected td { background: #d7eafb !important; }
.selectable-row.is-selected td:first-child { box-shadow: inset 3px 0 #2282d5; }
.document-list-scroll { height: clamp(260px, calc(100vh - 260px), 950px); border: 1px solid #dce2e9; }
.table-empty { height: 100px; }
.quiet-badge { background: transparent; color: #687483; font-size: calc(12px * var(--ui-text-scale, 1)); }
.table-secondary-text, .table-subtext { font-size: calc(11px * var(--ui-text-scale, 1)); }

.dashboard-shortcuts, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.dashboard-shortcut { min-height: 70px; padding: 13px 16px; font-size: calc(14px * var(--ui-text-scale, 1)); }
.dashboard-shortcut > span { width: 40px; height: 40px; }
.dashboard-shortcut .nav-icon { width: 20px; height: 20px; color: #fff; }
.metric-card { min-height: 105px; padding: 16px; }
.metric-label { max-width: none; color: #596471; font-size: calc(13px * var(--ui-text-scale, 1)); }
.metric-value { margin-top: 6px; font-size: calc(26px * var(--ui-text-scale, 1)); font-weight: 750; }
.metric-card[data-dashboard-metric="Receivable"] .metric-value { color: #e63c43; }
.metric-footnote { color: #7a838b; font-size: calc(11px * var(--ui-text-scale, 1)); }
.metric-icon { display: none; }
.dashboard-extra { margin-top: 10px; color: #266ca6; }
.dashboard-extra > summary { cursor: pointer; margin-bottom: 10px; font-size: calc(13px * var(--ui-text-scale, 1)); }

.invoice-history-tabs, .settings-tabs { display: flex; flex-wrap: wrap; gap: 0; margin: 0 0 12px; border-bottom: 1px solid #cdd6df; }
.invoice-history-tabs button, .settings-tabs button { min-height: 40px; padding: 0 15px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #30363d; font: inherit; font-size: calc(13px * var(--ui-text-scale, 1)); }
.invoice-history-tabs button.is-active, .settings-tabs button.is-active { border-color: #2282d5; color: #1767a8; font-weight: 700; }
.invoice-filter-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.invoice-filter-toolbar .date-range-presets { padding: 0; }
.invoice-filter-toolbar .search-field { flex: 0 1 320px; }
.invoice-filter-toolbar > .quiet-badge { margin-left: auto; }
.invoice-more-filters { position: relative; }
.invoice-more-filters > summary { display: flex; align-items: center; min-height: 38px; padding: 0 12px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; color: #30363d; cursor: pointer; font-size: calc(13px * var(--ui-text-scale, 1)); list-style: none; }
.invoice-more-filters > summary::-webkit-details-marker { display: none; }
.invoice-filter-popover { position: absolute; z-index: 10; top: calc(100% + 5px); left: 0; width: 290px; padding: 12px; border: 1px solid #cfd6df; border-radius: 6px; background: #fff; box-shadow: 0 5px 20px #1b304022; }
.cash-transactions-card, .cash-account-card { margin-top: 0; }
.cash-document-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.cash-document-toolbar .date-range-presets { padding: 0; }
.cash-document-toolbar > select { width: auto; min-width: 145px; }
.cash-document-toolbar .search-field { flex: 0 1 260px; }
.cash-transactions-card .document-list-scroll { height: clamp(240px, calc(100vh - 290px), 900px); }
.cash-transactions-card .data-table { min-width: 1200px; }
.cash-transactions-card .data-table th:last-child, .cash-transactions-card .data-table td:last-child { position: sticky; right: 0; z-index: 2; box-shadow: -1px 0 0 #d3e0ec; }
.cash-transactions-card .data-table th:last-child { z-index: 3; }
.cash-transactions-card .row-actions { display: inline-flex; flex-wrap: nowrap; gap: 8px; margin: 0 0 0 8px; }
.cash-transactions-card td:first-child, .cash-transactions-card td:nth-child(2), .cash-transactions-card td:nth-child(7), .cash-transactions-card td:nth-child(8), .cash-transactions-card td:last-child { white-space: nowrap; }
.cash-kind-badge { display: inline-block; border-radius: 12px; padding: 3px 8px; font-size: calc(11px * var(--ui-text-scale, 1)); font-weight: 700; white-space: nowrap; }
.cash-kind-receipt { color: #008866; background: #c9f4e4; }
.cash-kind-payment { color: #d5353e; background: #ffe1e3; }
.cash-kind-transfer, .cash-kind-opening { color: #1767a8; background: #dceeff; }
.cash-transactions-card .list-toolbar > strong { display: none; }
.cash-period-summary { display: flex; flex-wrap: wrap; gap: 12px; padding: 0 0 10px; }
.cash-period-metric { display: flex; align-items: baseline; gap: 6px; padding: 0; border: 0; background: transparent; }
.cash-period-metric span, .cash-period-metric strong { margin: 0; color: #596471; font-size: calc(12px * var(--ui-text-scale, 1)); }
.cash-period-metric:nth-child(2) strong { color: #009b78; }
.cash-period-metric:nth-child(3) strong { color: #e43f49; }
.cash-ledger-filters { align-items: end; margin-bottom: 12px; }
.cash-ledger-filters .date-range-presets { padding: 0; align-self: end; }
.cash-ledger-summary-scroll { max-width: 860px; }
.cash-ledger-summary-scroll .data-table { min-width: 620px; }
.data-table td.cash-ledger-in { color: #009b78; }
.data-table td.cash-ledger-out { color: #e43f49; }
.data-table tbody tr.cash-ledger-total td { background: #fff7d9; font-weight: 700; }
.cash-ledger-hint { margin: 12px 0; color: #596471; font-size: calc(12px * var(--ui-text-scale, 1)); }
.cash-ledger-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 12px 0; }
.cash-ledger .document-list-scroll { height: clamp(240px, calc(100vh - 390px), 700px); }

.report-shortcuts { gap: 16px; }
.report-shortcut-group { padding: 16px; }
.report-shortcut-group h2 { font-size: calc(14px * var(--ui-text-scale, 1)); }
.report-shortcut-group button { min-height: 38px; font-size: calc(13px * var(--ui-text-scale, 1)); }
.report-detail-heading { display: flex; align-items: center; gap: 24px; margin-bottom: 16px; }
.report-detail-heading .text-button { font-size: calc(13px * var(--ui-text-scale, 1)); }
.report-filter-card { padding: 0; border: 0; background: transparent; }
.report-filter-card .date-range-presets { padding: 12px 0; }
.report-result-card .table-toolbar { margin-bottom: 10px; }
.report-stock-summary { padding: 8px 0 12px; border: 0; background: transparent; }
.settings-tabs { margin-bottom: 14px; }
.settings-card { max-width: none; padding: 18px; }
.settings-radio-row { display: flex; flex-wrap: wrap; gap: 16px 28px; padding: 6px 0 14px; }
.settings-radio-row label { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; }
.payment-qr-preview { min-height: 80px; margin-top: 12px; }
.payment-qr-preview img { display: block; width: min(260px, 100%); height: auto; border: 1px solid #dce6f0; border-radius: 7px; }
.product-list-card { padding: 12px; }
.inventory-value-card { display: grid; gap: 4px; width: min(100%, 390px); margin-bottom: 12px; padding: 15px 18px; border: 1px solid #cddfed; border-radius: 8px; background: #fff; }
.inventory-value-label { color: #526276; font-size: calc(13px * var(--ui-text-scale, 1)); font-weight: 650; }
.inventory-value-card strong { color: #1767a8; font-size: calc(24px * var(--ui-text-scale, 1)); line-height: 1.2; }
#product-stock-value-note { color: #697887; font-size: calc(11px * var(--ui-text-scale, 1)); }
.product-toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.product-toolbar .search-field { width: min(280px, 100%); }
.product-toolbar select { width: min(190px, 100%); }
.product-toolbar select:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.product-negative-count { color: #d8401f; font-size: 13px; }
.audit-filter-form { align-items: end; margin-bottom: 16px; }
.audit-filter-form .audit-search { flex: 1; min-width: 230px; }
.audit-details { display: grid; gap: 4px; margin: 0; }
.audit-details > div { display: grid; grid-template-columns: minmax(8rem, 2fr) minmax(7rem, 3fr); gap: 8px; }
.audit-details dt { color: #526276; }
.audit-details dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
#catalog-import-preview { max-height: 360px; margin-top: 12px; }
.product-list-scroll { max-height: calc(100vh - 255px); min-height: 350px; overflow: auto; }
.product-list-table { min-width: 950px; }
.product-list-table:has(th:nth-child(9)) { min-width: 1180px; }
.product-list-table:has(th:nth-child(10)) { min-width: 1320px; }
.product-list-table thead th { position: sticky; top: 0; z-index: 2; background: #e4edf7; color: #155a9b; }
.product-list-table tbody tr:nth-child(even) { background: #eff4f8; }
.product-list-table tbody tr:hover { background: #e4f1fc; }
.product-list-table td { padding-top: 9px; padding-bottom: 9px; }
.product-list-table .table-subtext { display: block; margin-top: 3px; }
.product-list-table .product-stock-negative { color: #d92d20; font-weight: 700; }
.settings-section > .form-hint { margin: 0 0 14px; }
.settings-form .form-grid > label:not(.checkbox-field) { color: #303840; font-size: calc(13px * var(--ui-text-scale, 1)); }
.settings-form .form-grid input:not([type="checkbox"]), .settings-form select, .settings-form textarea { font-size: calc(13px * var(--ui-text-scale, 1)); }
.sales-policy-form { display: grid; gap: 14px; margin: 14px 0; }
.sales-policy-form > .button { justify-self: start; }
.sales-policy-grid { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 12px 24px; }
.sales-policy-grid > label:not(.sales-policy-toggle) { display: grid; gap: 5px; align-content: start; }
.sales-policy-grid input[type="text"], .sales-policy-grid select { width: 100%; }
.sales-policy-grid input[type="text"] { height: 38px; padding: 0 9px; border: 1px solid #dfe3ed; border-radius: 7px; }
.sales-policy-toggle, .sales-policy-accounts { display: flex; align-items: center; gap: 10px; }
.sales-policy-toggle input { appearance: none; flex: 0 0 38px; width: 38px; height: 22px; margin: 0; border: 0; border-radius: 999px; background: #d8dee5; cursor: pointer; }
.sales-policy-toggle input::before { content: ''; display: block; width: 16px; height: 16px; margin: 3px; border-radius: 50%; background: #fff; }
.sales-policy-toggle input:checked { background: #2282d5; }
.sales-policy-toggle input:checked::before { transform: translateX(16px); }
.sales-policy-toggle input:focus-visible { outline: 2px solid #176cbd; outline-offset: 2px; }
.sales-policy-toggle input:disabled { opacity: .55; cursor: default; }
.settings-advanced { margin: 0; padding: 0; border: 0; }
.settings-advanced > summary { display: none; }

.detail-drawer { position: fixed; inset: 0; z-index: 50; }
.detail-drawer-backdrop { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #10182066; }
.detail-drawer-sheet { position: absolute; top: 0; right: 0; bottom: 0; width: min(720px, 100vw); overflow-y: auto; padding: 22px; background: #fff; box-shadow: -8px 0 30px #132b4233; }
.detail-drawer-close { position: sticky; top: 0; z-index: 2; float: right; }
.detail-drawer .document-detail-card { margin: 0; padding-top: 4px; }
.detail-drawer .document-detail-card .card-heading { padding-right: 38px; }
.detail-drawer .document-detail-card .table-scroll { margin-top: 10px; }
.detail-drawer .document-detail-card .data-table { min-width: 620px; }
.app-dialog { border-radius: 8px; box-shadow: 0 18px 60px #182a3c40; }
.app-dialog::backdrop { background: #11182066; backdrop-filter: none; }
.dialog-heading { margin-bottom: 15px; }
.dialog-heading h2 { font-size: calc(18px * var(--ui-text-scale, 1)); }
.form-grid label, .conversion-row label, .sale-line-row label { font-size: calc(12px * var(--ui-text-scale, 1)); }
.form-grid input, .form-grid select, .conversion-row input, .sale-line-row input, .sale-line-row select { font-size: calc(13px * var(--ui-text-scale, 1)); }
.product-form-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.product-form-name { grid-column: span 4; }
.product-form-code, .product-form-unit, .product-form-barcode, .product-form-minimum { grid-column: span 2; }
.product-form-group, .product-form-price { grid-column: span 2; }
.conversion-row.has-catalog-prices { grid-template-columns: minmax(100px, 1.3fr) minmax(80px, .8fr) repeat(3, minmax(85px, 1fr)) 32px; }
.trade-entry-dialog .dialog-heading .eyebrow, .trade-entry-dialog .trade-entry-help, .trade-entry-dialog .form-section-heading p, .trade-entry-dialog #trade-form > .form-hint:first-of-type { display: none; }
.trade-entry-dialog .trade-order-tabs { margin-bottom: 10px; }
.trade-entry-dialog .dialog-form, .trade-entry-dialog .form-grid { gap: 9px; }
.trade-entry-dialog .trade-product-scan-row { padding: 7px; }
.trade-entry-dialog .sale-lines { gap: 0; }
.trade-line-header, .trade-line.sale-line-row { display: grid; min-width: 1060px; width: 100%; grid-template-columns: minmax(190px, 1.8fr) minmax(125px, 1.15fr) minmax(78px, .7fr) minmax(125px, 1.05fr) minmax(195px, 1.45fr) minmax(105px, .95fr) minmax(130px, 1fr) 34px; gap: 8px; padding: 7px 12px; }
.trade-line-header { border: 1px solid #d3e0ec; background: #e2edf9; color: #174b79; font-size: calc(12px * var(--ui-text-scale, 1)); font-weight: 700; }
.trade-line.sale-line-row { align-items: center; border: 0; border-bottom: 1px solid #dfe4e9; border-radius: 0; background: #fff; }
.trade-line .trade-line-label, .trade-line .trade-line-field-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }
.trade-line .trade-discount-field, .trade-line .sale-line-total { gap: 0; }
.trade-line .trade-discount-inputs { grid-template-columns: minmax(110px, 1.2fr) minmax(70px, .8fr); }
.trade-line .sale-line-remove { position: sticky; right: 0; z-index: 1; align-self: center; background: #fff; }

.sales-workspace-header { display: block; }
.sales-workspace-header h1 { margin-bottom: 13px; font-size: calc(21px * var(--ui-text-scale, 1)); }
.sales-workspace-actions { justify-content: flex-start; }
.sales-workspace-tabs { margin-top: 12px; }
.sales-order-panel { min-height: calc(100vh - 230px); }
.sales-order-toolbar label { font-size: calc(12px * var(--ui-text-scale, 1)); }
.sales-order-table th, .sales-order-table td { padding: 6px 5px; white-space: nowrap; }
.sales-order-table th:last-child { background: #e2edf9; }
.sales-order-table td:last-child:not([colspan]) { background: #fff; }
.sales-card-heading { display: block; }
.sales-card-heading button { margin-top: 8px; }
.sales-workspace:not(.purchase-workspace) .sales-card-heading button { white-space: nowrap; }
.sales-workspace:not(.purchase-workspace) .sales-customer-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sales-workspace:not(.purchase-workspace) .sales-customer-card .sales-note-label + .sales-note-label { margin-top: 8px; }
.sales-workspace:not(.purchase-workspace) .sales-summary-card > div { white-space: nowrap; overflow-x: auto; }
.sales-summary-card > div { font-size: calc(13px * var(--ui-text-scale, 1)); }
.purchase-workspace .sales-workspace-header h1 { color: #405de5; }
.purchase-workspace .purchase-summary-card { background: #edf2ff; }

@media (min-width: 1101px) {
  .purchase-workspace .sales-workspace-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .purchase-workspace .sales-workspace-header h1 { margin-bottom: 0; }
  .purchase-workspace .sales-workspace-actions { justify-content: flex-end; }
  .purchase-workspace .sales-workspace-grid { grid-template-columns: minmax(0, 1fr) minmax(220px, 25%); }
}

@media (min-width: 901px) {
  .sales-workspace-grid { grid-template-columns: minmax(0, 1fr) 200px; }
  .sales-workspace:not(.purchase-workspace) .sales-workspace-grid {
    grid-template-columns: minmax(0, 1fr) minmax(330px, 24%);
  }
  .sales-order-aside { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 701px) {
  .app-layout:not(.is-sidebar-collapsed) .nav-item > span:last-child { display: inline; }
}
@media (max-width: 900px) {
  .sales-workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .sales-order-panel { min-height: 300px; }
  .sales-order-aside { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topbar-user .user-copy { display: block; }
}
@media (max-width: 700px) {
  .app-layout, .app-layout.is-sidebar-collapsed { display: flex; flex-direction: column; }
  .workspace { display: contents; }
  .topbar { order: -2; width: 100%; min-height: 54px; height: 54px; padding: 0 10px; }
  .topbar-start { flex: 1; gap: 8px; }
  .topbar .brand-row strong { max-width: 36vw; font-size: calc(15px * var(--ui-text-scale, 1)); }
  .topbar .brand-mark { width: 32px; height: 32px; font-size: 16px; }
  .sidebar-collapse-toggle { display: none; }
  .mobile-menu-toggle { position: static; display: inline-flex; min-height: 34px; padding: 0 7px; border-color: #ffffff80; font-size: 12px; }
  .app-layout .sidebar, .app-layout.is-sidebar-collapsed .sidebar { display: none; position: fixed; top: 54px; bottom: 0; left: 0; z-index: 25; width: min(270px, 85vw); height: auto; padding: 10px; box-shadow: 5px 0 18px #17304b22; }
  .app-layout .sidebar.is-menu-open { display: flex; }
  .sidebar.is-menu-open .main-navigation { display: flex; width: 100%; align-items: stretch; padding: 0; }
  .sidebar .nav-item, .app-layout.is-sidebar-collapsed .nav-item { width: 100%; justify-content: flex-start; padding: 0 13px; border: 0; text-align: left; font-size: 13px; }
  .sidebar .nav-item .nav-icon { display: block; }
  .sidebar .nav-item span:not(.nav-icon), .app-layout.is-sidebar-collapsed .nav-item > span:last-child { display: inline; }
  .sidebar .sidebar-bottom, .sidebar.is-menu-open .sidebar-bottom { display: block; margin-top: auto; padding: 12px 6px 0; }
  .page-content, .is-sales-entry .page-content { width: 100%; padding: 14px 12px 28px; }
  .page-heading { flex-direction: row; align-items: center; flex-wrap: wrap; }
  .page-actions { width: auto; }
  .topbar-actions { gap: 4px; }
  .topbar-user .user-copy, .help-label, .text-size-label { display: none; }
  .text-size-picker select { width: 66px; min-width: 66px; padding: 0 3px; }
  .topbar-action { width: 32px; padding: 0; }
  .dashboard-shortcuts, .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .dashboard-shortcut { min-height: 58px; gap: 8px; padding: 8px; font-size: 12px; }
  .dashboard-shortcut > span { width: 34px; height: 34px; }
  .metric-card { min-height: 90px; padding: 12px; }
  .metric-value { margin-top: 6px; font-size: 21px; }
  .report-shortcuts { grid-template-columns: minmax(0, 1fr); }
  .sales-order-aside { grid-template-columns: minmax(0, 1fr); }
  .sales-workspace-header { display: block; }
  .sales-workspace-actions { width: auto; }
  .detail-drawer-sheet { padding: 15px; }
  .product-form-grid { grid-template-columns: minmax(0, 1fr); }
  .product-form-name, .product-form-code, .product-form-unit, .product-form-barcode, .product-form-minimum, .product-form-group, .product-form-price { grid-column: 1; }
  .conversion-row.has-catalog-prices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .conversion-row.has-catalog-prices .conversion-remove { grid-column: 2; justify-self: end; }
}

.print-settings-layout { display: grid; grid-template-columns: minmax(240px, 0.8fr) minmax(0, 2fr); align-items: start; gap: 16px; }
.print-settings-controls { grid-template-columns: minmax(0, 1fr); align-content: start; padding: 4px 0; }
.print-preview-panel { min-width: 0; padding: 14px; border: 1px solid #d3dae2; border-radius: 7px; background: #eef1f4; }
.print-preview-toolbar { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.print-preview-toolbar label { display: flex; flex: 1 1 220px; flex-direction: column; gap: 5px; color: #303840; font-size: calc(13px * var(--ui-text-scale, 1)); font-weight: 600; }
.print-preview-toolbar select { width: 100%; }
.print-preview-panel .form-hint { margin: 10px 0; }
.print-preview-frame { display: block; width: 100%; height: min(950px, 110vh); min-height: 600px; border: 1px solid #cdd6df; background: #fff; box-shadow: 0 2px 8px #17263b1a; }
@media (max-width: 860px) {
  .print-settings-layout { grid-template-columns: minmax(0, 1fr); }
  .print-preview-frame { height: 680px; min-height: 480px; }
}

.settings-section[data-settings-section="print"] { container-type: inline-size; min-width: 0; }
.print-settings-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.print-settings-controls, .print-preview-toolbar label { min-width: 0; }
.print-preview-toolbar input[type="file"] { width: 100%; min-width: 0; }
.print-preview-frame { min-width: 0; max-width: 100%; }
@container (max-width: 760px) {
  .print-settings-layout { grid-template-columns: minmax(0, 1fr); }
}

#print-column-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-width: 0;
  margin: 12px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}
.print-preview-panel [hidden] { display: none !important; }
.print-layout-order { padding: 0; list-style: none; display: grid; gap: 5px; }
.print-layout-order li { display: flex; align-items: center; gap: 8px; padding: 5px 8px; border: 1px solid var(--line); border-radius: 6px; background: white; cursor: grab; }
.print-layout-order li span { flex: 1; }
.print-layout-order button { min-width: 30px; min-height: 28px; border: 1px solid var(--line); border-radius: 4px; background: white; }
#print-column-options legend { padding: 0 6px; font-weight: 650; }

.data-table .row-select-cell { width: 42px; text-align: center; }
.row-select-cell input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; vertical-align: middle; }
.table-selection-export { margin: 8px 12px; }
.icon-actions { display: flex; align-items: center; gap: 4px; }
.action-icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: #1766ad;
  vertical-align: middle;
}
.action-icon-button svg { width: 17px; height: 17px; pointer-events: none; }
.action-icon-button:hover { background: #fff; border-color: currentColor; }
.action-icon-button:focus-visible { outline: 2px solid currentColor; outline-offset: 1px; }
.action-icon-adjust, .action-icon-post, .action-icon-sale { color: #087451; }
.action-icon-tracking, .action-icon-merge { color: #6f42a1; }
.action-icon-unpost, .action-icon-return { color: #975318; }
.action-icon-delete, .action-icon-cancel { color: #b22d36; }
#print-field-palette { min-width: 0; padding: 12px 0; border-top: 1px solid var(--line); }
#print-field-palette h3, #print-field-palette h4 { margin: 6px 0; }
#print-field-palette h4 { color: #175da0; }
.print-field-chips, .print-editor-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.print-field-chips button { padding: 5px 8px; border: 1px solid #8abcef; border-radius: 5px; background: #eaf5ff; color: #164e83; cursor: grab; font: inherit; }
.print-editor-tabs [aria-pressed="true"], .print-format-toolbar [aria-pressed="true"] { background: #eaf5ff; border-color: #5694d2; color: #164e83; }
.print-format-toolbar { margin-top: 8px; padding: 8px; background: white; border: 1px solid var(--line); border-radius: 6px; align-items: center; }
.print-format-toolbar label { flex: 0 1 auto; }
.print-format-toolbar input[type="number"] { width: 104px; }
.invoice-print-frame { height: 60vh; min-height: 280px; }
.app-dialog.product-catalog-dialog { width: min(800px, calc(100% - 24px)); max-width: 800px; padding: 16px; }
.product-catalog-dialog .product-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 10px; }
.product-catalog-dialog .product-form-name { grid-column: span 8; }
.product-catalog-dialog .product-form-code, .product-catalog-dialog .product-form-unit { grid-column: span 4; }
.product-catalog-dialog .product-form-group { grid-column: span 8; order: 1; }
.product-catalog-dialog .product-form-price, .product-catalog-dialog .product-form-minimum { grid-column: span 3; order: 2; }
.product-catalog-dialog .product-form-barcode, .product-catalog-dialog .product-form-warehouse { grid-column: span 6; order: 3; }
.product-conversion-scroll { overflow-x: auto; border: 1px solid #d8e1ec; }
.product-conversion-head, .product-catalog-dialog .conversion-row { display: grid; grid-template-columns: 1fr 1fr 32px; gap: 8px; padding: 5px; min-width: 260px; align-items: center; }
.product-conversion-head.has-catalog-prices, .product-catalog-dialog .conversion-row.has-catalog-prices { grid-template-columns: repeat(5, minmax(80px, 1fr)) 32px; min-width: 500px; }
.product-conversion-head { background: #e0ebf7; color: #174d7e; font-weight: 700; }
.product-catalog-dialog .conversion-row { margin: 0; border: 0; border-bottom: 1px solid #e0e7ef; border-radius: 0; }
.product-catalog-dialog .conversion-row input { width: 100%; min-width: 0; }
.product-catalog-options { margin-top: 10px; }
@media (max-width: 600px) {
  .product-catalog-dialog .product-form-grid > label { grid-column: span 6; }
  .product-catalog-dialog .product-form-grid > .product-form-name { grid-column: 1 / -1; }
}
.app-dialog.customer-profile-dialog { width: min(440px, calc(100% - 24px)); padding: 16px; }
.customer-profile-dialog .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.customer-profile-dialog details > label { display: block; margin-top: 8px; }
.product-form-group:has(select) { display: flex; align-items: end; gap: 8px; min-width: 0; }
.product-form-group:has(select) > label { flex: 1; min-width: 0; }
.sales-order-toolbar select, #debt-terms-form textarea {
  min-width: 0;
  border: 1px solid #dfe3ed;
  border-radius: 7px;
  background: #fff;
  color: #29324b;
  padding: 0 9px;
  font: inherit;
}
.sales-order-toolbar select { min-height: 38px; min-width: 125px; }
#debt-terms-form textarea { width: 100%; min-height: 58px; padding: 8px 9px; resize: vertical; }
.sales-order-toolbar select:focus, #debt-terms-form textarea:focus { outline: 2px solid #8cbcf0; outline-offset: 1px; }
.cash-category-editor { display: grid; gap: 12px; }
#staff-accounts tr[hidden] { display: none; }
