/* Persistent business screens inside the original green ERP page.
   The sidebar, header, flyout navigation and original order layout stay owned
   by orders.html / colors_and_type.css. No former blue app shell is imported. */

body[data-erp-mode="live"] .app-layout { position: fixed; inset: 0; }
body[data-erp-mode="live"] .sidebar { min-height: 0; overflow-y: auto; overflow-x: hidden; }

#workspace-focus:empty { display: none; }
#workspace-focus { flex: none; padding: 5px 14px; background: #ECFDF5; border-bottom: 1px solid #D1FAE5; }
#workspace-focus button { border: 0; background: transparent; color: #047857; cursor: pointer; margin-left: 8px; }

.green-content,
#app {
  display: flex;
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
#app {
  background: var(--color-bg-body, #F0F2F5);
  color: var(--color-text-primary, #1A1A2E);
  font: 13px/1.5 var(--font-sans, "Microsoft YaHei", Arial, sans-serif);
}
#app *,
#modal *,
#dialog * {
  box-sizing: border-box;
}

/* Open business pages share the merchant page's compact white tab strip. */
#workspace-tabs.workspace-tabs {
  display: flex;
  flex: 0 0 34px;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  min-height: 34px;
  padding: 0 8px;
  overflow-x: auto;
  overflow-y: hidden;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
  background: #fff;
  scrollbar-width: thin;
  font: 13px/1.4 var(--font-sans, "Microsoft YaHei", Arial, sans-serif);
}
#workspace-tabs .workspace-tab {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: #fff;
  color: var(--color-text-secondary, #6B7280);
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
#workspace-tabs .workspace-tab:hover,
#workspace-tabs .workspace-tab.active {
  color: var(--color-primary, #059669);
  background: #F0FDF4;
}
#workspace-tabs .workspace-tab.active {
  border-bottom-color: var(--color-primary, #059669);
  font-weight: 600;
}
#workspace-tabs .workspace-tab span[data-close-tab],
#workspace-tabs .workspace-tab .workspace-close,
#workspace-tabs .workspace-tab .tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 3px;
  border-radius: 3px;
  color: #9CA3AF;
  font-size: 14px;
  line-height: 1;
}
#workspace-tabs .workspace-tab span[data-close-tab]:hover,
#workspace-tabs .workspace-tab .workspace-close:hover,
#workspace-tabs .workspace-tab .tab-close:hover {
  background: var(--color-primary-light, #D1FAE5);
  color: var(--color-primary, #059669);
}
#workspace-tabs .workspace-all {
  flex: 0 0 auto;
  margin-left: auto;
  padding: 0 10px;
  border: 0;
  background: #fff;
  color: var(--color-primary, #059669);
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
}
#workspace-tabs button:focus-visible {
  outline: 2px solid var(--color-primary, #059669);
  outline-offset: -3px;
}

/* Controls are scoped so the original navigation retains its own styling. */
:where(#app, #modal, #dialog) button,
:where(#app, #modal, #dialog) input,
:where(#app, #modal, #dialog) select,
:where(#app, #modal, #dialog) textarea {
  font: inherit;
}
:where(#app, #modal, #dialog) button {
  cursor: pointer;
}
:where(#app, #modal, #dialog) button:disabled {
  cursor: not-allowed;
  opacity: .45;
}
:where(#app, #modal, #dialog) a {
  color: var(--color-primary, #059669);
  text-decoration: none;
}
:where(#app, #modal, #dialog) a:hover {
  color: var(--color-primary-hover, #047857);
}
:where(#app, #modal, #dialog) input,
:where(#app, #modal, #dialog) select,
:where(#app, #modal, #dialog) textarea {
  min-width: 0;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: 4px;
  background: #fff;
  color: var(--color-text-primary, #1A1A2E);
  padding: 5px 8px;
}
:where(#app, #modal, #dialog) input:not([type="checkbox"]):not([type="radio"]),
:where(#app, #modal, #dialog) select {
  min-height: 30px;
}
:where(#app, #modal, #dialog) input:focus,
:where(#app, #modal, #dialog) select:focus,
:where(#app, #modal, #dialog) textarea:focus {
  outline: 1px solid var(--color-primary, #059669);
  outline-offset: 0;
  border-color: var(--color-primary, #059669);
}
:where(#app, #modal, #dialog) input[type="checkbox"],
:where(#app, #modal, #dialog) input[type="radio"] {
  width: 14px;
  height: 14px;
  min-height: 0;
  margin-right: 4px;
  padding: 0;
  accent-color: var(--color-primary, #059669);
  vertical-align: -2px;
  cursor: pointer;
}
:where(#app, #modal, #dialog) textarea {
  resize: vertical;
}
:where(#app, #modal, #dialog) button:focus-visible,
:where(#app, #modal, #dialog) a:focus-visible {
  outline: 2px solid var(--color-primary, #059669);
  outline-offset: 2px;
}
:where(#app, #modal, #dialog) button.primary,
:where(#app, #modal, #dialog) button.secondary {
  min-height: 30px;
  padding: 4px 12px;
  border-radius: 4px;
  white-space: nowrap;
}
:where(#app, #modal, #dialog) button.primary {
  color: #fff;
  background: var(--color-primary, #059669);
  border: 1px solid var(--color-primary, #059669);
}
:where(#app, #modal, #dialog) button.primary:hover:not(:disabled) {
  background: var(--color-primary-hover, #047857);
  border-color: var(--color-primary-hover, #047857);
}
:where(#app, #modal, #dialog) button.secondary {
  background: #fff;
  color: var(--color-text-primary, #1A1A2E);
  border: 1px solid var(--color-border, #E5E7EB);
}
:where(#app, #modal, #dialog) button.secondary:hover:not(:disabled) {
  color: var(--color-primary, #059669);
  border-color: var(--color-primary, #059669);
}
:where(#app, #modal, #dialog) button.link {
  border: 0;
  background: none;
  color: var(--color-primary, #059669);
  padding: 3px 6px;
  white-space: nowrap;
}
:where(#app, #modal, #dialog) button.danger,
:where(#app, #modal, #dialog) button.link.danger {
  color: var(--state-error, #EF4444);
}
:where(#app, #modal, #dialog) .negative {
  color: var(--state-error, #EF4444);
}
:where(#app, #modal, #dialog) .positive {
  color: var(--color-primary, #059669);
}
:where(#app, #modal, #dialog) .muted,
:where(#app, #modal, #dialog) .tiny {
  color: var(--color-text-tertiary, #9CA3AF);
  font-size: 11px;
}
:where(#app, #modal, #dialog) .spacer {
  flex: 1 1 auto;
}

/* Business page layout. Wide records scroll inside their table, not the shell. */
#app .page-main {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: #fff;
}
#app .basic-filter {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px 9px;
  padding: 10px 14px;
  background: #F9FAFB;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
}
#app .basic-filter label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--color-text-secondary, #6B7280);
}
#app .basic-filter input:not([type="checkbox"]) {
  width: 210px;
  max-width: 100%;
}
#app .basic-filter select {
  max-width: 240px;
}
#app .toolbar {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px 8px;
  min-height: 41px;
  padding: 6px 10px;
  background: #fff;
  border: 0;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
}
#app .toolbar label {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  color: var(--color-text-secondary, #6B7280);
}
#app .note {
  flex: 0 0 auto;
  padding: 7px 14px;
  color: #92400E;
  background: var(--state-warning-bg, #FFFBEB);
  border-bottom: 1px solid #FDE68A;
  font-size: 12px;
  line-height: 1.6;
}
#app .section-title {
  flex: 0 0 auto;
  height: auto;
  min-height: 38px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
  color: var(--color-text-primary, #1A1A2E);
  font-size: 13px;
  font-weight: 500;
}
#app .table-wrap {
  flex: 1 1 180px;
  min-width: 0;
  min-height: 120px;
  max-height: none;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  overscroll-behavior: contain;
}
:where(#app, #modal, #dialog) .grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  white-space: nowrap;
  font-size: 12px;
}
:where(#app, #modal, #dialog) .grid th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 8px 10px;
  background: var(--color-bg-table-header, #FAFBFC);
  color: var(--color-text-secondary, #6B7280);
  border-right: 1px solid #F0F0F0;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
  font-weight: 500;
  font-size: 12px;
  white-space: nowrap;
}
:where(#app, #modal, #dialog) .grid td {
  padding: 8px 10px;
  border-right: 1px solid #F5F5F5;
  border-bottom: 1px solid #F0F0F0;
  vertical-align: middle;
  max-width: 320px;
}
:where(#app, #modal, #dialog) .grid th:last-child,
:where(#app, #modal, #dialog) .grid td:last-child {
  border-right: 0;
}
:where(#app, #modal, #dialog) .grid tbody tr:nth-child(even) td {
  background: var(--color-bg-table-stripe, #F8FAFC);
}
:where(#app, #modal, #dialog) .grid tbody tr:hover td {
  background: #F0FDF4;
}
:where(#app, #modal, #dialog) .grid tr.selected td {
  background: var(--color-primary-light, #D1FAE5);
}
:where(#app, #modal, #dialog) .grid .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
:where(#app, #modal, #dialog) .grid .number {
  color: var(--color-primary, #059669);
  font-family: var(--font-mono, Consolas, monospace);
}
:where(#app, #modal, #dialog) .grid .select-col {
  width: 34px;
  text-align: center;
}
:where(#app, #modal, #dialog) .grid .wrap {
  min-width: 180px;
  max-width: 260px;
  white-space: normal;
  overflow-wrap: anywhere;
}
:where(#app, #modal, #dialog) .grid .product-cell {
  min-width: 230px;
}
#app .business-grid {
  min-width: 1050px;
}
#app .business-grid td {
  min-width: 85px;
  white-space: normal;
  overflow-wrap: anywhere;
}
#app .business-grid td:last-child {
  min-width: 155px;
}
#app .compact-grid td {
  height: auto;
  min-height: 44px;
}

/* The live order workspace keeps the original 220px query pool and column
   geometry. Wide tables scroll instead of squeezing order information. */
#app .merchant-orders-main {
  flex: 1 1 auto;
  min-width: 0;
}
#app .merchant-order-query {
  flex: 0 0 220px;
  width: 220px;
  min-width: 220px;
  overflow-y: auto;
}
#app .merchant-order-query[hidden] {
  display: none;
}
#app .merchant-order-query .ofp-search-item {
  align-items: stretch;
}
#app .merchant-order-query .ofp-search-input {
  width: 0;
  min-height: 28px;
  height: 28px;
  padding: 0 6px;
  border-radius: 4px 0 0 4px;
  border-right: 0;
  font-size: 12px;
}
#app .merchant-query-label {
  display: inline-flex;
  flex: 0 0 90px;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 5px;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: 0 4px 4px 0;
  background: #F9FAFB;
  color: var(--color-text-secondary, #6B7280);
  font-size: 11px;
  white-space: nowrap;
}
#app .merchant-order-query .merchant-date {
  flex: 1 1 auto;
  width: 140px;
  min-width: 0;
  margin-left: 6px;
  padding: 4px;
  font-size: 11px;
}
#app .merchant-order-query .error {
  padding: 6px;
  color: var(--state-error, #EF4444);
  font-size: 11px;
  white-space: normal;
}
#app .merchant-order-query .error[hidden] {
  display: none;
}
#app .merchant-orders-main .status-tabs {
  flex: 0 0 auto;
}
#app .merchant-orders-main .status-tabs button {
  flex: 0 0 auto;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  background: transparent;
  font: inherit;
  font-size: 12px;
}
#app .merchant-orders-main .status-tabs button.active {
  border-bottom-color: #064E3B;
  color: #064E3B;
}
#app .merchant-orders-main .order-toolbar,
#app .merchant-orders-main .archive-banner,
#app .merchant-orders-main .table-tips-bar,
#app .merchant-orders-main .pagination {
  flex: 0 0 auto;
}
#app .merchant-orders-main .toolbar-row {
  flex-wrap: wrap;
  gap: 5px;
}
#app .merchant-order-table-wrap {
  min-height: 120px;
  overflow: auto;
}
#app .merchant-order-grid tbody tr:not(.summary-row) {
  height: 72px;
}
#app .merchant-order-grid tbody td {
  padding: 6px 10px;
}
#app .merchant-order-grid .cb-cell,
#app .merchant-order-grid .col-action {
  z-index: 1;
}
#app .merchant-order-grid thead .cb-cell,
#app .merchant-order-grid thead .col-action {
  z-index: 3;
  background: var(--color-bg-table-header, #FAFBFC);
}
#app .merchant-order-grid tr.selected .cb-cell,
#app .merchant-order-grid tr.selected .col-action {
  background: var(--color-primary-light, #D1FAE5);
}
#app .merchant-cell-wrap {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  max-width: 200px;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}
#app .merchant-cell-wrap.order-num {
  max-width: 160px;
}
#app .merchant-cell-wrap .row-action {
  max-width: 100%;
  padding: 0;
  text-align: left;
  white-space: normal;
  overflow-wrap: anywhere;
}
#app .merchant-row-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px 1px;
  width: 118px;
}
#app .merchant-row-actions .row-action {
  height: 20px;
  padding: 0 3px;
  white-space: nowrap;
  text-align: left;
  font-size: 11px;
  line-height: 20px;
}
#app .merchant-order-product {
  min-width: 0;
  gap: 6px;
}
#app .merchant-order-product + .merchant-order-product {
  margin-top: 3px;
}
#app .merchant-order-product .product-thumb {
  width: 28px;
  height: 28px;
  font-size: 11px;
}
#app .merchant-order-product .product-name {
  max-width: 220px;
  line-height: 16px;
}
#app .merchant-order-product .product-sku {
  margin-top: 0;
  line-height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#app .merchant-empty {
  padding: 30px 16px;
  color: var(--color-text-tertiary, #9CA3AF);
  text-align: center;
}
#app .merchant-order-grid .platform-local {
  background: var(--color-primary-light, #D1FAE5);
  color: var(--color-primary-dark, #065F46);
}
#app .merchant-orders-main .pagination {
  flex-wrap: wrap;
  gap: 8px;
}
#app .merchant-orders-main .pagination-info,
#app .merchant-orders-main .pagination-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
}
#app .merchant-orders-main .page-jump {
  width: 48px;
  min-height: 26px;
  padding: 3px;
}
:where(#modal, #dialog) .merchant-columns-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 14px;
}
:where(#modal, #dialog) .merchant-columns-grid label {
  display: flex;
  align-items: center;
  min-height: 28px;
  font-size: 12px;
}
#app .audit-log .grid td {
  padding-top: 7px;
  padding-bottom: 7px;
}
#app .footer {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 7px 12px;
  height: auto;
  min-height: 38px;
  padding: 7px 12px;
  background: #FAFBFC;
  color: var(--color-text-secondary, #6B7280);
  border-top: 1px solid var(--color-border, #E5E7EB);
  font-size: 12px;
}
#app .footer .pager {
  display: flex;
  align-items: center;
  gap: 8px;
}
#app .footer button {
  min-height: 28px;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: 4px;
  background: #fff;
  color: var(--color-text-secondary, #6B7280);
  padding: 3px 8px;
}
#app .footer button:hover:not(:disabled) {
  border-color: var(--color-primary, #059669);
  color: var(--color-primary, #059669);
}

/* Platform colors remain distinct from the green product theme. */
:where(#app, #modal, #dialog) .pill {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #A7F3D0;
  border-radius: 3px;
  background: #ECFDF5;
  color: var(--color-primary-dark, #065F46);
  font-size: 11px;
  white-space: nowrap;
}
:where(#app, #modal, #dialog) .pill.pdd {
  border-color: #FECACA;
  color: var(--color-pdd, #E02E24);
  background: var(--color-pdd-bg, #FEF2F2);
}
:where(#app, #modal, #dialog) .pill.taobao {
  border-color: #FED7AA;
  color: var(--color-taobao, #FF5000);
  background: var(--color-taobao-bg, #FFF7ED);
}
:where(#app, #modal, #dialog) .status {
  color: var(--color-text-secondary, #6B7280);
}
:where(#app, #modal, #dialog) .status.ready {
  color: var(--color-primary-dark, #065F46);
}
:where(#app, #modal, #dialog) .status.shipped {
  color: var(--state-success, #10B981);
}
#app .product-thumb {
  display: inline-flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid #D1FAE5;
  border-radius: 4px;
  background: #F0FDF4;
  color: var(--color-primary, #059669);
}
#app .stock-summary {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  padding: 9px 14px;
  background: #fff;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
  color: var(--color-text-secondary, #6B7280);
  font-size: 12px;
}
#app .stock-summary strong {
  margin-left: 6px;
  color: var(--color-text-primary, #1A1A2E);
  font-size: 16px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
#app .stock-summary strong.negative {
  color: var(--state-error, #EF4444);
}
#app .cards {
  display: grid;
  flex: 1 1 auto;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: start;
  gap: 14px;
  min-width: 0;
  padding: 16px;
  overflow: auto;
}
#app .card {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: var(--radius-md, 8px);
  background: #fff;
}
#app .page-main > .card {
  flex: 0 0 auto;
  margin: 10px 14px;
}
#app .card h3 {
  margin: 0 0 12px;
  color: var(--color-text-primary, #1A1A2E);
  font-size: 14px;
  font-weight: 500;
}
#app .card-row {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 7px 15px;
  margin: 8px 0;
  color: var(--color-text-secondary, #6B7280);
  font-size: 12px;
}
#app .card-row strong {
  color: var(--color-text-primary, #1A1A2E);
  font-weight: 500;
}
#app .report-cards {
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 12px 14px;
  background: #F9FAFB;
}
#app .report-cards .card {
  padding: 13px;
  font-size: 12px;
}
#app .report-cards strong {
  display: block;
  margin-top: 5px;
  color: var(--color-primary, #059669);
  font-size: 21px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
#app .card-row strong.negative,
#app .report-cards strong.negative {
  color: var(--state-error, #EF4444);
}
:where(#app, #modal, #dialog) .empty {
  padding: 45px 16px;
  color: var(--color-text-tertiary, #9CA3AF);
  text-align: center;
}
#app .loading {
  width: 100%;
  padding: 60px 20px;
  color: var(--color-text-secondary, #6B7280);
  text-align: center;
}

/* Modal markup and form classes are shared with the persistent business logic. */
#modal,
#dialog {
  width: min(740px, 94vw);
  max-width: calc(100vw - 24px);
  max-height: 88vh;
  margin: auto;
  padding: 0;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: var(--radius-md, 8px);
  box-shadow: 0 12px 40px rgba(6, 78, 59, .2);
  background: #fff;
  color: var(--color-text-primary, #1A1A2E);
  font: 13px/1.5 var(--font-sans, "Microsoft YaHei", Arial, sans-serif);
  overflow: hidden;
}
#modal::backdrop,
#dialog::backdrop {
  background: rgba(17, 24, 39, .35);
}
:where(#modal, #dialog) .dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--color-border, #E5E7EB);
  font-size: 15px;
  font-weight: 500;
}
:where(#modal, #dialog) .dialog-head button {
  border: 0;
  background: none;
  color: var(--color-text-tertiary, #9CA3AF);
  font-size: 23px;
  line-height: 1;
}
:where(#modal, #dialog) .dialog-body {
  max-height: 64vh;
  padding: 18px;
  overflow: auto;
  overscroll-behavior: contain;
}
:where(#modal, #dialog) .dialog-body h3 {
  margin: 14px 0 10px;
  font-size: 13px;
  font-weight: 500;
}
:where(#modal, #dialog) .dialog-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  padding: 11px 18px;
  border-top: 1px solid var(--color-border, #E5E7EB);
  background: #FAFBFC;
}
:where(#modal, #dialog) .form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px 18px;
  margin-bottom: 14px;
}
:where(#modal, #dialog) .form-grid label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
  color: var(--color-text-secondary, #6B7280);
  font-size: 12px;
}
:where(#modal, #dialog) .form-grid input:not([type="checkbox"]):not([type="radio"]),
:where(#modal, #dialog) .form-grid select,
:where(#modal, #dialog) .form-grid textarea {
  width: 100%;
}
:where(#modal, #dialog) .form-grid .wide {
  grid-column: 1 / -1;
}
:where(#modal, #dialog) .form-grid textarea {
  min-height: 65px;
}
:where(#modal, #dialog) .message {
  padding: 10px 12px;
  margin-bottom: 14px;
  border: 1px solid #A7F3D0;
  border-radius: 4px;
  color: var(--color-primary-dark, #065F46);
  background: #ECFDF5;
  line-height: 1.8;
}
:where(#modal, #dialog) .error {
  margin-bottom: 14px;
  padding: 8px 12px;
  border: 1px solid #FECACA;
  border-radius: 4px;
  color: #DC2626;
  background: var(--state-error-bg, #FEF2F2);
}
:where(#modal, #dialog) .error[hidden] {
  display: none;
}
:where(#modal, #dialog) .detail-list {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 9px 12px;
  margin-bottom: 14px;
}
:where(#modal, #dialog) .detail-list dt {
  color: var(--color-text-tertiary, #9CA3AF);
}
:where(#modal, #dialog) .detail-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}
:where(#modal, #dialog) .grid th {
  position: static;
}
:where(#modal, #dialog) .grid td {
  height: auto;
}
:where(#modal, #dialog) .toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  margin: 10px 0;
  padding: 6px 0;
  border: 0;
  background: transparent;
}
:where(#modal, #dialog) .table-wrap {
  overflow-x: auto;
  max-height: none;
}
:where(#modal, #dialog) .business-grid {
  min-width: 460px;
}
:where(#modal, #dialog) .entry-scroll {
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
}
:where(#modal, #dialog) .entry-grid {
  min-width: 530px;
}
:where(#modal, #dialog) .entry-grid td {
  padding: 7px;
}
:where(#modal, #dialog) .entry-grid select {
  width: 240px;
}
:where(#modal, #dialog) .entry-grid input {
  width: 80px;
}
:where(#modal, #dialog) .entry-grid .item-total {
  min-width: 65px;
  font-variant-numeric: tabular-nums;
}
:where(#modal, #dialog) .stock-entry-available,
:where(#modal, #dialog) .item-stock {
  margin-top: 4px;
}
:where(#modal, #dialog) .file-picker {
  margin-top: 15px;
  padding: 22px;
  border: 1px dashed #6EE7B7;
  border-radius: 4px;
  background: #F0FDF4;
}
:where(#modal, #dialog) .file-picker input {
  width: 100%;
  margin-top: 10px;
  border: 0;
  background: transparent;
}

/* Existing guidance and records reuse the same content components. */
#app .guide {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  overflow: auto;
  background: var(--color-bg-body, #F0F2F5);
}
#app .guide h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 500;
}
#app .guide p {
  color: var(--color-text-secondary, #6B7280);
  line-height: 1.8;
}
#app .guide-step {
  display: flex;
  gap: 14px;
  margin: 14px 0;
  padding: 16px;
  border: 1px solid var(--color-border, #E5E7EB);
  border-radius: var(--radius-md, 8px);
  background: #fff;
}
#app .step-number {
  display: grid;
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: var(--color-primary-light, #D1FAE5);
  color: var(--color-primary-dark, #065F46);
}
#app .guide-step h3 {
  margin: 1px 0 8px;
  font-size: 14px;
  font-weight: 500;
}
#app .guide-step p {
  margin: 0;
}
#app .guide-step a {
  display: inline-block;
  margin-top: 8px;
}
#app .guide-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}
#app .guide-status span {
  padding: 4px 10px;
  border: 1px solid #FDE68A;
  border-radius: 3px;
  color: #92400E;
  background: var(--state-warning-bg, #FFFBEB);
}
#app .guide .message {
  padding: 10px 12px;
  margin-top: 14px;
  border: 1px solid #A7F3D0;
  color: var(--color-primary-dark, #065F46);
  background: #ECFDF5;
}

#toast {
  position: fixed;
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: none;
  max-width: calc(100vw - 32px);
  padding: 10px 18px;
  border: 1px solid #A7F3D0;
  border-radius: 4px;
  box-shadow: 0 5px 20px rgba(6, 78, 59, .12);
  color: var(--color-primary-dark, #065F46);
  background: #fff;
  font: 13px/1.6 var(--font-sans, "Microsoft YaHei", Arial, sans-serif);
}
#toast.error-toast {
  border-color: #FECACA;
  color: #DC2626;
  background: var(--state-error-bg, #FEF2F2);
}

/* Business documents have their own A5 output, without changing stock. */
#print-area {
  display: none;
}
:where(#modal, #dialog, #print-area) .packing {
  margin: 10px 0;
  padding: 15px;
  border: 1px solid #9CA3AF;
  background: #fff;
  color: #111;
}
:where(#modal, #dialog, #print-area) .packing h2 {
  margin: 5px 0 15px;
  text-align: center;
  font-size: 22px;
}
:where(#modal, #dialog, #print-area) .packing-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px;
  padding-bottom: 10px;
  border-bottom: 1px solid #D1D5DB;
}
:where(#modal, #dialog, #print-area) .packing p {
  margin: 8px 0;
}
:where(#modal, #dialog, #print-area) .packing table {
  width: 100%;
  margin: 12px 0;
  border-collapse: collapse;
  font-size: 13px;
}
:where(#modal, #dialog, #print-area) .packing td,
:where(#modal, #dialog, #print-area) .packing th {
  padding: 7px;
  border: 1px solid #D1D5DB;
  text-align: left;
  overflow-wrap: anywhere;
}
:where(#modal, #dialog, #print-area) .signature {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding-top: 15px;
  font-size: 12px;
}
:where(#modal, #dialog, #print-area) .print-note {
  color: #6B7280;
  font-size: 11px;
}
:where(#modal, #dialog) .print-options {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

@media (max-width: 760px) {
  #app .basic-filter {
    padding: 8px 10px;
  }
  #app .basic-filter input:not([type="checkbox"]) {
    width: 180px;
  }
  #app .toolbar {
    gap: 5px;
  }
  #app .stock-summary {
    gap: 7px 16px;
  }
  #app .report-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 10px;
  }
  #app .report-cards strong {
    font-size: 18px;
  }
  #app .card {
    padding: 12px;
  }
  :where(#modal, #dialog) .form-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }
  :where(#modal, #dialog) .dialog-body {
    padding: 14px;
  }
  :where(#modal, #dialog) .entry-grid select {
    width: 210px;
  }
}
@media (max-width: 430px) {
  #app .cards {
    grid-template-columns: minmax(0, 1fr);
    padding: 10px;
  }
  #app .basic-filter input:not([type="checkbox"]) {
    width: 100%;
  }
  #app .basic-filter label {
    max-width: 100%;
  }
  :where(#modal, #dialog) .detail-list {
    grid-template-columns: 80px minmax(0, 1fr);
    gap: 7px;
  }
}
@media print {
  @page {
    size: A5 portrait;
    margin: 8mm;
  }
  html,
  body {
    height: auto !important;
    overflow: visible !important;
    background: #fff !important;
  }
  .app-layout,
  #app,
  #modal,
  #dialog,
  #toast {
    display: none !important;
  }
  #print-area {
    display: block !important;
    color: #111;
    font: 12px/1.5 var(--font-sans, "Microsoft YaHei", Arial, sans-serif);
  }
  #print-area .packing {
    margin: 0;
    padding: 0;
    border: 0;
    break-after: page;
    page-break-after: always;
  }
  #print-area .packing:last-child {
    break-after: auto;
    page-break-after: auto;
  }
  #print-area .packing table {
    font-size: 11px;
  }
  #print-area .packing h2 {
    font-size: 20px;
  }
  #print-area .packing-header,
  #print-area .print-note {
    font-size: 11px;
    color: #111;
  }
}
