/* Business-page styles loaded after the shared desktop/mobile layout. */
.audit-page { display: grid; gap: 14px; }
.audit-filter-card { padding: 14px; }
.audit-filter-grid { display: grid; grid-template-columns: repeat(2, minmax(145px, .75fr)) minmax(170px, 1fr) minmax(150px, .8fr) minmax(135px, .7fr) minmax(220px, 1.3fr) auto; gap: 10px; align-items: center; }
.audit-table { overflow: auto; }
.audit-table table { min-width: 1040px; }
.audit-table td { vertical-align: top; }
.audit-table td small { display: block; margin-top: 4px; color: var(--muted, #718096); }
.audit-table code { font-size: 12px; white-space: nowrap; }
.audit-change-detail summary { cursor: pointer; color: #3658db; white-space: nowrap; }
.audit-change-detail pre { max-width: 420px; max-height: 260px; overflow: auto; margin: 8px 0 0; padding: 10px; border-radius: 8px; background: #f7f9fc; color: #334155; font: 12px/1.55 ui-monospace, SFMono-Regular, Consolas, monospace; white-space: pre-wrap; word-break: break-word; }
.audit-error { color: #b42318; background: #fff5f5; border-color: #fecaca; }

@media (max-width: 1280px) {
  .audit-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .audit-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .audit-filter-grid input[placeholder] { grid-column: 1 / -1; }
  .audit-filter-grid .btn { grid-column: 1 / -1; }
  .audit-table { margin-inline: 0; border-radius: 12px; }
}

/* Dashboard workbench (option E) */
.dashboard-trend-card { margin-top: 16px; padding: 18px 20px 12px; border: 1px solid #dfe7f5; border-radius: 16px; background: linear-gradient(145deg, #fff, #f7faff); box-shadow: 0 10px 28px rgba(31,57,110,.07); }
.dashboard-trend-head,.dashboard-trend-total { display:flex; align-items:center; justify-content:space-between; gap:12px; }
.dashboard-trend-head>div:first-child { display:grid; gap:3px; }
.dashboard-trend-head strong { font-size:18px; }
.dashboard-trend-head span,.dashboard-trend-total span { color:#718096; font-size:13px; }
.dashboard-trend-tabs { display:flex; padding:3px; border-radius:10px; background:#edf2fc; }
.dashboard-trend-tabs button { border:0; border-radius:8px; padding:7px 13px; color:#60708c; background:transparent; cursor:pointer; }
.dashboard-trend-tabs button.active { color:#2854d9; background:#fff; box-shadow:0 2px 8px rgba(37,78,176,.12); }
.dashboard-trend-total { margin-top:12px; justify-content:flex-start; }
.dashboard-trend-total strong { color:#2455df; font-size:24px; }
.dashboard-trend-chart { width:100%; overflow:hidden; }
.dashboard-trend-chart svg { display:block; width:100%; height:190px; }
.trend-axis { stroke:#dce4f2; stroke-width:1; }
.trend-grid { stroke:#e8edf6; stroke-width:1; stroke-dasharray:5 5; }
.trend-line { fill:none; stroke:#3561e8; stroke-width:3; stroke-linecap:round; stroke-linejoin:round; }
.dashboard-trend-chart circle { fill:#fff; stroke:#3561e8; stroke-width:2.5; }
.dashboard-trend-chart text { fill:#7a879d; font-size:11px; }
.order-document-mobile-items { display:none; }
.order-document-mobile-view,.product-mobile-actions { display:none; }
.product-desktop-actions { display:flex; align-items:center; gap:10px; }

/* Mobile compact card layout (option A) and dashboard workbench (option E) */
@media (max-width: 720px) {
  html,body { max-width:100%; overflow-x:hidden; }
  body { font-size:14px; }
  .content { min-width:0; padding:12px 12px calc(92px + env(safe-area-inset-bottom)); }
  .topbar { min-height:68px; padding:10px 14px; }
  .topbar h1,.page-title { font-size:24px; line-height:1.25; }
  .topbar .page-subtitle { display:none; }
  .card,.customer-card,.order-card,.product-mobile-item,.cost-order-card { border-radius:14px; }
  .input,.select,.btn { min-height:44px; font-size:14px; }
  .toolbar { gap:8px; margin-bottom:10px; }
  .toolbar>.input { min-width:0; width:100%; }
  .hint,.meta,small { line-height:1.45; }
  .badge { white-space:nowrap; }
  .mobile-table-head { margin:8px 0 6px; padding:8px 12px; border-radius:10px; font-size:12px; }

  .route-customers .filter-toolbar { display:grid; grid-template-columns:minmax(0,1fr) auto; }
  .route-customers #customerSearchInput { grid-column:1/-1; }
  .route-customers .filter-toolbar .compact-select { width:100%; }
  .route-customers .customer-mobile-head { display:none; }
  .customer-list { display:grid; gap:9px; }
  .customer-card { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:8px 10px; padding:13px; }
  .customer-main { min-width:0; }
  .customer-name { font-size:17px; line-height:1.35; word-break:break-word; }
  .customer-main .meta { display:flex; flex-wrap:wrap; gap:3px 12px; margin-top:5px; }
  .customer-stats { grid-column:1/-1; display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; padding:8px 0; border-block:1px solid #edf1f7; }
  .customer-stats span { min-width:0; font-size:12px; overflow-wrap:anywhere; }
  .customer-actions { grid-column:1/-1; display:flex; justify-content:flex-end; gap:7px; }
  .customer-actions .icon-btn { min-width:44px; min-height:44px; }

  .route-create .create-order-meta-card,.route-returns .create-order-meta-card { padding:12px; margin-bottom:10px!important; }
  .create-order-summary { min-height:52px; }
  .create-order-summary strong { font-size:17px; }
  .create-order-summary small { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .create-order-meta-grid { gap:10px; }
  .mobile-product-filters { top:68px; padding:8px 0 6px; background:#f4f7fc; z-index:8; }
  .product-search-row { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:7px; }
  .product-search-row .btn { padding-inline:12px; }
  .category-tabs,.subcategory-tabs { gap:7px; padding-bottom:3px; overflow-x:auto; scrollbar-width:none; }
  .category-tabs button,.subcategory-tabs button { min-height:38px; padding:7px 13px; white-space:nowrap; }
  .route-create .product-grid,.route-returns .product-grid { display:grid; grid-template-columns:1fr; gap:0; overflow:hidden; border:1px solid #e0e7f2; border-radius:14px; background:#fff; }
  .route-create .product-card,.route-returns .product-card { display:grid; grid-template-columns:58px minmax(0,1fr) auto; min-height:88px; gap:10px; padding:11px; border:0; border-bottom:1px solid #e8edf5; border-radius:0; box-shadow:none; overflow:visible; }
  .route-create .product-card:last-child,.route-returns .product-card:last-child { border-bottom:0; }
  .route-create .product-card .product-thumb-button.catalog,.route-returns .product-card .product-thumb-button.catalog { width:58px; height:58px; grid-row:1/span 2; }
  .route-create .product-card>:nth-child(2),.route-returns .product-card>:nth-child(2) { min-width:0; align-self:center; }
  .route-create .product-card strong,.route-returns .product-card strong { display:-webkit-box; overflow:hidden; font-size:15px; line-height:1.35; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow-wrap:anywhere; }
  .route-create .product-card .product-card-qty,.route-returns .product-card .product-card-qty { position:static; grid-column:3; grid-row:1/span 2; align-self:center; min-width:44px; max-width:116px; }
  .route-create .product-card .price,.route-returns .product-card .price { font-size:18px; }

  .route-orders .order-filter-toolbar { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .route-orders #orderSearchInput { grid-column:1/-1; }
  .route-orders .order-filter-toolbar .spacer { display:none; }
  .route-orders .order-filter-toolbar>.btn { grid-column:1/-1; }
  .order-mobile-head { display:none; }
  .order-list { gap:9px; }
  .order-card-body { padding:13px 12px; min-width:0; }
  .order-card-head { align-items:flex-start; gap:8px; }
  .order-card-title-row { min-width:0; gap:5px; }
  .order-card-title-row h3 { max-width:100%; font-size:16px; overflow-wrap:anywhere; }
  .order-amount,.order-amount-button { flex:0 0 auto; max-width:42%; font-size:20px; }
  .order-card-meta-grid { display:flex; flex-wrap:wrap; gap:5px 12px; }
  .order-card-meta-grid span { min-width:0; font-size:12px; }
  .order-card-address { width:100%; overflow-wrap:anywhere; }
  .order-card-bottom { display:grid; gap:8px; }
  .order-icon-toolbar { width:100%; justify-content:space-between; }

  .route-products .toolbar { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); }
  .route-products #productSearchInput { grid-column:1/-1; }
  .route-products .toolbar .spacer { display:none; }
  .route-products .toolbar .btn { padding-inline:8px; }
  .product-mobile-list { gap:8px; }
  .product-mobile-item { display:grid; grid-template-columns:auto 52px minmax(0,1fr) auto; gap:8px; padding:11px; align-items:start; overflow:hidden; }
  .product-mobile-item .product-thumb-button { width:52px; height:52px; }
  .product-mobile-info { min-width:0; gap:2px; }
  .product-mobile-info strong { font-size:15px; line-height:1.35; overflow-wrap:anywhere; }
  .product-mobile-info span,.product-mobile-info small { overflow-wrap:anywhere; }
  .product-mobile-side { align-items:flex-end; }
  .product-mobile-side>strong { font-size:18px; color:#2858df; }
  .product-mobile-item>.row-actions { grid-column:2/-1; display:flex; justify-content:flex-end; gap:7px; padding-top:7px; border-top:1px solid #eef2f7; }
  .product-mobile-item>.row-actions button { min-width:44px; min-height:44px; }

  .route-costs .cost-summary-grid { display:grid; grid-template-columns:repeat(6,minmax(0,1fr)); gap:8px; }
  .route-costs .cost-summary-item { grid-column:span 2; min-width:0; padding:11px 9px; }
  .route-costs .cost-summary-item:nth-child(4),.route-costs .cost-summary-item:nth-child(5) { grid-column:span 3; }
  .route-costs .cost-summary-item span { font-size:11px; line-height:1.3; }
  .route-costs .cost-summary-item strong { display:block; margin-top:5px; font-size:17px; overflow-wrap:anywhere; }
  .cost-order-head { display:grid; gap:10px; }
  .cost-card-metrics { width:100%; grid-template-columns:repeat(3,minmax(0,1fr)); }
  .cost-order-meta { display:flex; flex-wrap:wrap; gap:5px 12px; }
  .cost-compact-summary { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .cost-expand-btn { grid-column:1/-1; width:100%; }

  .ai-modal { width:100%; height:100dvh; max-height:100dvh; border-radius:0; }
  .ai-modal .modal-head { padding:15px 14px; }
  .ai-modal .modal-body { padding:10px 12px 100px; overflow-x:hidden; }
  .ai-master-detail { display:block; min-width:0; }
  .ai-result-master,.ai-result-detail { width:100%; min-width:0; max-height:none; border:0; }
  .ai-master-list { display:grid; grid-template-columns:1fr; overflow:visible; }
  .ai-nav-item { width:100%; min-width:0; }
  .ai-detail-panel { padding:13px 0; }
  .ai-candidate-card,.ai-search-results>* { min-width:0; overflow-wrap:anywhere; }
  .ai-modal .modal-foot { position:fixed; left:0; right:0; bottom:0; z-index:4; padding:10px 12px calc(10px + env(safe-area-inset-bottom)); background:rgba(255,255,255,.97); }

  .order-document-modal { width:100%; height:100dvh; max-height:100dvh; border-radius:0; }
  .order-document-modal .modal-body { padding:10px; }
  .order-document-modal .doc-preview table { display:none; }
  .order-document-mobile-items { display:grid; margin:12px 0; border-top:1px solid #e2e8f2; }
  .order-document-mobile-items article { display:grid; grid-template-columns:28px minmax(0,1fr) auto; gap:8px; padding:11px 0; border-bottom:1px solid #e2e8f2; align-items:start; }
  .order-document-mobile-items article>div { display:grid; min-width:0; gap:3px; }
  .order-document-mobile-items strong,.order-document-mobile-items small { overflow-wrap:anywhere; }
  .order-document-mobile-items small { color:#718096; }
  .order-document-mobile-items article>b { color:#2455df; white-space:nowrap; }
  .document-item-index { display:grid; place-items:center; width:26px; height:26px; border-radius:8px; color:#315ce1; background:#edf2ff; }
  .doc-info { grid-template-columns:1fr; }
  .doc-address { grid-column:1; overflow-wrap:anywhere; }

  .route-dashboard .dashboard-filter-row { margin-bottom:10px; }
  .route-dashboard .dashboard-metrics { padding:0; }
  .route-dashboard .dashboard-section-head { margin:14px 1px 8px; }
  .route-dashboard .dashboard-metric-grid.month-metrics { display:flex; gap:8px; padding:1px 1px 5px; overflow-x:auto; scroll-snap-type:x proximity; scrollbar-width:none; }
  .route-dashboard .month-metrics .dashboard-metric { flex:0 0 46%; min-width:0; min-height:118px; padding:13px 11px; scroll-snap-align:start; }
  .route-dashboard .dashboard-metric-value { max-width:100%; font-size:clamp(18px,5.2vw,26px); line-height:1.15; white-space:nowrap; letter-spacing:-.3px; }
  .route-dashboard .dashboard-metric-note { display:none; }
  .route-dashboard .today-metrics { grid-template-columns:repeat(3,minmax(0,1fr)); gap:8px; }
  .route-dashboard .today-metrics .dashboard-metric { min-width:0; min-height:92px; padding:11px 8px; }
  .route-dashboard .today-metrics .dashboard-metric-value { font-size:18px; }
  .route-dashboard .dashboard-metric-icon { display:none; }
  .dashboard-trend-card { margin-top:10px; padding:14px 12px 8px; border-radius:14px; }
  .dashboard-trend-head strong { font-size:16px; }
  .dashboard-trend-tabs button { min-height:36px; padding:6px 10px; }
  .dashboard-trend-total strong { font-size:21px; }
  .dashboard-trend-chart svg { height:165px; }
  .route-dashboard>.two-col { display:block; margin-top:10px!important; }
  .route-dashboard>.two-col>.card { padding:12px; }
  .route-dashboard>.two-col>.card+.card { display:none; }
  .route-dashboard .order-card { margin-top:8px; }

  .modal-backdrop { z-index:1200; }
  .modal-foot { padding-bottom:calc(10px + env(safe-area-inset-bottom)); }
  .pagination { flex-wrap:wrap; gap:7px; }
  .pagination span { width:100%; }
}

/* Faithful mobile implementation of the selected option A (dashboard: option E). */
@media (max-width: 720px) {
  :root { --mobile-page-gap: 8px; }
  body { font-size: 13px; background:#f4f7fc; }
  .main,.app-shell.has-mobile-cart .main { padding-bottom:calc(64px + env(safe-area-inset-bottom)); }
  .app-shell.has-mobile-cart .main { padding-bottom:calc(118px + env(safe-area-inset-bottom)); }
  .topbar {
    position:relative;
    min-height:46px;
    padding:8px 10px;
    border-bottom:1px solid #e4e9f2;
    background:#fff;
  }
  .topbar > div:first-child { min-width:0; }
  .topbar h1,.topbar .page-title { margin:0; font-size:17px; line-height:30px; }
  .topbar .page-subtitle,.topbar > .toolbar,.route-products .topbar > .toolbar { display:none!important; }
  .content { padding:8px 8px calc(68px + env(safe-area-inset-bottom)); }
  .has-mobile-cart .content { padding-bottom:calc(126px + env(safe-area-inset-bottom)); }
  .input,.select,.btn { min-height:38px; font-size:13px; }
  .filter-field label,.field label { font-size:11px; }
  .card,.customer-card,.order-card,.product-mobile-item,.cost-order-card { border-radius:9px; }
  .mobile-bottom-nav {
    min-height:calc(54px + env(safe-area-inset-bottom));
    padding:2px 4px env(safe-area-inset-bottom);
    box-shadow:0 -4px 16px rgba(35,55,96,.09);
  }
  .mobile-bottom-nav button { min-height:50px; gap:0; border-radius:8px; font-size:10px; }
  .mobile-bottom-nav .nav-icon { width:23px; height:23px; font-size:12px; border-radius:7px; }
  .mobile-cart-bar {
    right:8px; bottom:calc(56px + env(safe-area-inset-bottom)); left:8px;
    min-height:52px; padding:4px 5px; border-radius:12px;
  }
  .mobile-cart-summary { min-height:42px; }
  .mobile-cart-icon { width:34px; height:34px; flex-basis:34px; }
  .mobile-cart-open { min-width:104px; min-height:40px; }

  /* Sales creation: compact customer summary and no empty spacer below it. */
  .route-create .create-order-meta-card,.route-returns .create-order-meta-card {
    min-height:0!important; height:auto!important; margin:0 0 7px!important; padding:0!important; overflow:hidden!important;
  }
  .create-order-summary { min-height:48px; padding:7px 10px; border-radius:9px; }
  .create-order-summary strong { font-size:14px; }
  .create-order-summary small { font-size:10.5px; }
  .create-order-meta-details:not(.is-open) { display:none!important; height:0!important; min-height:0!important; padding:0!important; border:0!important; overflow:hidden!important; }
  .create-order-meta-details.is-open { padding:8px; }
  .route-create .create-product-layout,.route-returns .create-product-layout,
  .route-create .create-product-column,.route-returns .create-product-column { min-height:0!important; margin:0!important; gap:0!important; }
  .mobile-product-filters {
    position:relative!important; top:auto!important; z-index:auto!important;
    margin:0 0 5px!important; padding:0!important; background:transparent!important; box-shadow:none!important;
  }
  .mobile-product-filters .toolbar { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:6px; margin:0 0 5px; }
  .mobile-product-filters .desktop-cart-trigger { display:none!important; }
  .mobile-product-filters .toolbar .input,.mobile-product-filters .toolbar .btn { min-height:38px; height:38px; }
  .mobile-product-filters .category-tabs,.mobile-product-filters .subcategory-tabs { margin:0; gap:5px; }
  .mobile-product-filters .category-tabs button,.mobile-product-filters .subcategory-tabs button { min-height:34px; padding:5px 11px; font-size:12px; }
  .mobile-product-filters .subcategory-panel { margin-top:5px; }
  .create-product-column .product-count-hint { margin:5px 2px; font-size:11px; }
  .route-create .product-grid,.route-returns .product-grid { border-radius:9px; }
  .route-create .product-card,.route-returns .product-card { min-height:72px; grid-template-columns:48px minmax(0,1fr) auto; gap:8px; padding:7px 8px; }
  .route-create .product-card .product-thumb-button.catalog,.route-returns .product-card .product-thumb-button.catalog { width:48px; height:48px; }
  .route-create .product-card strong,.route-returns .product-card strong { font-size:13.5px; line-height:1.3; }
  .route-create .product-card .product-spec,.route-returns .product-card .product-spec { font-size:10.5px; }
  .route-create .product-card .price,.route-returns .product-card .price { font-size:16px; }
  .route-create .product-card .product-card-qty,.route-returns .product-card .product-card-qty { max-width:108px; }
  .create-product-column .product-card-qty button,.create-product-column .product-add-btn { width:38px; height:38px; min-width:38px; min-height:38px; }
  .create-product-column .product-card-qty .qty-input { width:34px; height:36px; }

  /* Orders: one compact search row, one three-column filter row and denser cards. */
  .route-orders .order-filter-toolbar { grid-template-columns:repeat(3,minmax(0,1fr)); gap:6px; margin-bottom:7px; }
  .route-orders #orderSearchInput { grid-column:1/-1; min-height:38px; }
  .route-orders .order-filter-toolbar>.btn { display:none; }
  .route-orders .order-filter-toolbar .filter-field label { margin-bottom:2px; font-size:10px; }
  .route-orders .order-filter-toolbar .select { min-height:36px; padding:5px 8px; font-size:11px; }
  .order-list { gap:6px; }
  .order-card-polished .order-card-body { padding:8px 9px; }
  .order-card-polished .order-card-title-row h3 { font-size:14px; }
  .order-card-polished .order-amount { font-size:18px; }
  .order-card-polished .order-card-meta-grid { gap:3px 8px; font-size:11px; }
  .order-card-polished .order-card-address { min-height:27px; padding:4px 7px; font-size:11px; }
  .order-card-polished .order-icon-toolbar { min-height:35px; margin-top:4px; padding-top:4px; }

  /* Products: selected A layout—three primary actions, low-frequency exports in More. */
  .route-products .content > .product-management-toolbar { position:relative; display:block; margin-bottom:6px; }
  .route-products .product-management-toolbar #productSearchInput { width:100%; min-height:38px; margin-bottom:6px; }
  .product-desktop-actions { display:none!important; }
  .product-mobile-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
  .product-mobile-actions>.btn { min-height:36px; padding:5px 4px; font-size:11px; }
  .route-products .category-tabs { margin:5px 0; }
  .route-products .category-tabs button { min-height:34px; padding:5px 11px; font-size:12px; }
  .product-list-summary { margin:4px 1px 6px; }
  .product-mobile-head { margin-bottom:4px; }
  .product-mobile-list { gap:4px; }
  .product-mobile-item {
    grid-template-columns:42px minmax(0,1fr) 64px 102px;
    gap:6px; min-height:64px; padding:7px; align-items:center; overflow:visible;
  }
  .product-mobile-item .product-thumb-button.small { grid-column:1; grid-row:1; width:42px; height:42px; }
  .product-mobile-info { grid-column:2; grid-row:1; }
  .product-mobile-info strong { display:-webkit-box!important; overflow:hidden!important; white-space:normal!important; text-overflow:clip!important; -webkit-box-orient:vertical; -webkit-line-clamp:2; font-size:13px; }
  .product-mobile-info span,.product-mobile-info small { overflow:hidden!important; white-space:nowrap!important; text-overflow:ellipsis!important; font-size:10.5px; }
  .product-mobile-side { grid-column:3; grid-row:1; align-self:center; }
  .product-mobile-side>strong { font-size:15px; }
  .product-mobile-item>.row-actions { grid-column:4; grid-row:1; align-self:center; padding:0; border:0; gap:3px; }
  .product-mobile-item>.row-actions .icon-btn { width:32px; height:32px; min-width:32px; min-height:32px; padding:7px; }
  .product-mobile-select { top:2px; left:2px; width:24px; height:24px; }

  /* Customers: selected A rows include clear action labels. */
  .customer-card { grid-template-columns:minmax(0,1fr) 126px; padding:8px 9px; gap:4px 8px; }
  .customer-name { font-size:14px; }
  .customer-card .meta,.customer-stats span { font-size:10.5px; }
  .customer-stats { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:2px 6px; white-space:normal; }
  .customer-stats span { min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .customer-actions { gap:2px; }
  .customer-actions .icon-btn { display:flex; width:40px; min-width:40px; height:auto; min-height:42px; padding:4px 2px; flex-direction:column; gap:1px; font-size:9px; }
  .customer-actions .icon-btn svg { width:16px; height:16px; }
  .customer-actions .icon-btn::after { content:attr(aria-label); display:block; max-width:38px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:8px; }
  .customer-actions .icon-btn[aria-label="历史订单"]::after { content:"详情"; }
  .customer-actions .icon-btn[aria-label="删除客户"]::after { content:"删除"; }

  /* AI order: horizontal compact master strip above the selected item detail. */
  .ai-modal .modal-head { min-height:48px; padding:9px 10px; }
  .ai-modal .modal-head h3 { font-size:17px; }
  .ai-modal .modal-head .hint { display:none; }
  .ai-modal .modal-body { padding:7px 8px 70px; }
  .ai-master-detail { display:grid; grid-template-rows:auto minmax(0,1fr); min-height:0; }
  .ai-result-master { max-height:none; padding-bottom:6px; border:0; border-bottom:1px solid #e3e9f3; }
  .ai-master-head { padding:5px 2px; }
  .ai-master-head>div:first-child { display:none; }
  .ai-status-summary { flex-wrap:nowrap; gap:4px; overflow-x:auto; }
  .ai-status-chip { flex:0 0 auto; padding:5px 8px; font-size:11px; }
  .ai-master-list { display:flex; grid-template-columns:none; gap:6px; max-height:none; padding:2px; overflow-x:auto; overflow-y:hidden; scroll-snap-type:x proximity; }
  .ai-nav-item { flex:0 0 228px; width:228px; min-height:104px; padding:9px; scroll-snap-align:start; }
  .ai-result-detail { max-height:none; overflow:visible; }
  .ai-detail-panel { padding:10px 2px; }
  .ai-detail-panel:not(.active) { display:none!important; }
  .ai-modal .modal-foot { padding:7px 8px calc(7px + env(safe-area-inset-bottom)); }
  .ai-modal .modal-foot .btn { min-height:40px; }

  /* Order details: a native mobile information page, not a shrunken desktop invoice. */
  .order-document-modal .modal-head { min-height:48px; padding:8px 10px; background:#315de5; color:#fff; }
  .order-document-modal .modal-head h3 { font-size:15px; }
  .order-document-modal .modal-head .icon-btn { color:#fff; border-color:rgba(255,255,255,.35); background:rgba(255,255,255,.1); }
  .order-document-modal .modal-body { padding:8px; background:#f4f7fc; }
  .order-document-mobile-view { display:grid; gap:7px; }
  .order-document-modal .document-toolbar,.order-document-modal .doc-preview { display:none!important; }
  .order-document-mobile-summary { display:grid; gap:8px; padding:10px; border:1px solid #dfe6f2; border-radius:9px; background:#fff; }
  .order-document-mobile-title,.order-document-mobile-total { display:flex; align-items:center; justify-content:space-between; gap:8px; }
  .order-document-mobile-title>div { display:grid; min-width:0; gap:1px; }
  .order-document-mobile-title span,.order-document-mobile-total span { color:#71809a; font-size:10px; }
  .order-document-mobile-title strong { overflow-wrap:anywhere; font-size:14px; }
  .order-document-mobile-title>b { padding:4px 7px; border-radius:999px; color:#315de5; background:#edf2ff; font-size:10px; }
  .order-document-mobile-total strong { color:#2858df; font-size:22px; }
  .order-document-mobile-total small { margin-left:auto; color:#71809a; }
  .order-document-mobile-meta { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:5px 10px; }
  .order-document-mobile-meta span,.order-document-mobile-address { display:flex; min-width:0; gap:5px; font-size:11px; overflow-wrap:anywhere; }
  .order-document-mobile-meta b,.order-document-mobile-address b { flex:0 0 auto; color:#71809a; }
  .order-document-mobile-address { padding:6px 7px; border-radius:6px; background:#f5f7fb; }
  .order-document-mobile-section-title { display:flex; justify-content:space-between; padding:7px 2px 3px; }
  .order-document-mobile-section-title span { color:#71809a; }
  .order-document-mobile-list { display:grid; border:1px solid #dfe6f2; border-radius:9px; background:#fff; overflow:hidden; }
  .order-document-mobile-list article { display:grid; grid-template-columns:25px minmax(0,1fr) auto; gap:7px; align-items:start; padding:8px; border-bottom:1px solid #e8edf5; }
  .order-document-mobile-list article:last-child { border-bottom:0; }
  .order-document-mobile-list article>div { display:grid; min-width:0; gap:2px; }
  .order-document-mobile-list article strong { overflow-wrap:anywhere; font-size:12px; }
  .order-document-mobile-list article small,.order-document-mobile-list article span { color:#71809a; font-size:10.5px; }
  .order-document-mobile-list article>b { color:#2858df; white-space:nowrap; }
  .order-document-mobile-remark { display:flex; gap:8px; padding:8px 10px; border:1px solid #dfe6f2; border-radius:9px; background:#fff; }
  .order-document-mobile-remark b { flex:0 0 auto; }
  .order-document-mobile-actions { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
  .order-document-mobile-actions .btn { min-width:0; min-height:38px; padding:5px; gap:4px; font-size:11px; }
  .order-document-mobile-actions svg { width:15px; }

  /* Costs: five metrics in a readable 3 + 2 arrangement. */
  .route-costs .cost-summary-grid { grid-template-columns:repeat(6,minmax(0,1fr)); gap:5px; }
  .route-costs .cost-summary-item { grid-column:span 2; padding:8px 6px; }
  .route-costs .cost-summary-item:nth-child(4),.route-costs .cost-summary-item:nth-child(5) { grid-column:span 3; }
  .route-costs .cost-summary-item span { font-size:9.5px; }
  .route-costs .cost-summary-item strong { font-size:15px; }

  /* Dashboard E: four visible month cards, today's row and trend chart. */
  .route-dashboard .topbar { background:#315de5; border-color:#315de5; }
  .route-dashboard .topbar h1 { color:#fff; }
  .route-dashboard .dashboard-metric-grid.month-metrics { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:6px; overflow:visible; }
  .route-dashboard .month-metrics .dashboard-metric { min-height:82px; padding:9px; }
  .route-dashboard .dashboard-metric-value { font-size:18px; white-space:normal; overflow-wrap:anywhere; }
  .route-dashboard .today-metrics { gap:5px; }
  .route-dashboard .today-metrics .dashboard-metric { min-height:70px; padding:8px 6px; }
  .route-dashboard .today-metrics .dashboard-metric-value { font-size:16px; }
  .dashboard-trend-card { padding:10px 9px 5px; }
  .dashboard-trend-chart svg { height:130px; }
}

@media (max-width: 390px) {
  .product-mobile-item { grid-template-columns:38px minmax(0,1fr) 58px 72px; gap:5px; }
  .product-mobile-item .product-thumb-button.small { width:38px; height:38px; }
  .product-mobile-item>.row-actions .icon-btn { width:23px; height:32px; min-width:23px; padding:5px; }
  .route-orders .order-filter-toolbar { grid-template-columns:repeat(2,minmax(0,1fr)); }
  .route-orders .order-filter-toolbar .filter-field:last-of-type { grid-column:1/-1; }
}

/* Final mobile layout correction: selected A pages and selected E dashboard. */
.cart-line-delete { align-self:center; }
.cart-line-delete .icon-btn { width:30px; height:30px; }
.cart-price-input { display:inline-flex; align-items:center; gap:3px; }
.cart-price-input b { color:var(--text); font-weight:700; }
.cart-line { grid-template-columns:minmax(0,1fr) 32px; align-items:center; }
.cart-line-main { grid-column:1; grid-row:1; }
.cart-line-delete { grid-column:2; grid-row:1; }
.cart-line-side {
  grid-column:1/-1; grid-row:2; display:grid;
  grid-template-columns:minmax(130px,1fr) auto minmax(80px,.5fr);
  align-items:center; justify-items:stretch; gap:8px;
}
.cart-line-total { text-align:right; }

@media (max-width:0px) {
  /* Selected E dashboard: four month metrics and three daily metrics stay compact. */
  .route-dashboard .topbar { min-height:48px!important; padding:8px 12px!important; }
  .route-dashboard .topbar h1 { font-size:20px!important; }
  .route-dashboard .content { padding-top:9px!important; }
  .route-dashboard .dashboard-sales-filter { margin-bottom:9px!important; }
  .route-dashboard .dashboard-sales-filter label { margin-bottom:3px!important; font-size:10px!important; }
  .route-dashboard .dashboard-sales-filter .select { min-height:34px!important; height:34px!important; font-size:12px!important; }
  .route-dashboard .dashboard-section-head { margin:9px 1px 5px!important; }
  .route-dashboard .dashboard-section-head strong { font-size:15px!important; }
  .route-dashboard .dashboard-section-head span { font-size:10.5px!important; }
  .route-dashboard .dashboard-metric-grid.month-metrics {
    display:grid!important; grid-template-columns:repeat(4,minmax(0,1fr))!important;
    gap:4px!important; overflow:visible!important;
  }
  .route-dashboard .month-metrics .dashboard-metric {
    min-width:0!important; min-height:62px!important; padding:6px 5px!important;
    border-radius:8px!important; box-shadow:0 2px 7px rgba(31,48,80,.07)!important;
  }
  .route-dashboard .dashboard-metric-label { font-size:9px!important; line-height:1.2!important; }
  .route-dashboard .month-metrics .dashboard-metric-value {
    max-width:100%!important; margin-top:4px!important; font-size:clamp(9.5px,2.75vw,11px)!important;
    line-height:1.08!important; letter-spacing:-.65px!important; white-space:nowrap!important;
    overflow:visible!important;
  }
  .route-dashboard .today-metrics {
    display:grid!important; grid-template-columns:repeat(3,minmax(0,1fr))!important; gap:4px!important;
  }
  .route-dashboard .today-metrics .dashboard-metric { min-height:58px!important; padding:6px!important; border-radius:8px!important; }
  .route-dashboard .today-metrics .dashboard-metric-value { font-size:clamp(12px,3.7vw,16px)!important; white-space:nowrap!important; }
  .route-dashboard .dashboard-metric-note,.route-dashboard .dashboard-metric-hint,.route-dashboard .dashboard-metric-icon { display:none!important; }
  .route-dashboard .dashboard-trend-card { margin-top:9px!important; padding:8px 8px 3px!important; border-radius:10px!important; }
  .route-dashboard .dashboard-trend-card h3 { font-size:15px!important; }
  .route-dashboard .dashboard-trend-total { margin:4px 0!important; }
  .route-dashboard .dashboard-trend-total strong { font-size:20px!important; }
  .route-dashboard .dashboard-trend-chart svg { height:116px!important; }
  .route-dashboard .grid.two-col { margin-top:9px!important; gap:7px!important; }

  /* Selected A customer rows: information and actions have separate columns. */
  .route-customers .content { padding-top:8px!important; }
  .route-customers .filter-toolbar { display:grid!important; grid-template-columns:minmax(0,1fr) auto!important; gap:5px!important; margin-bottom:7px!important; }
  .route-customers .filter-toolbar #customerSearchInput { grid-column:1/-1!important; min-height:36px!important; height:36px!important; }
  .route-customers .filter-toolbar .select { min-width:0!important; width:100%!important; }
  .route-customers .filter-toolbar .select,.route-customers .filter-toolbar .btn { min-height:34px!important; height:34px!important; padding:4px 9px!important; font-size:11px!important; }
  .customer-list { gap:5px!important; }
  .customer-card {
    display:grid!important; grid-template-columns:minmax(0,1fr) 112px!important;
    grid-template-rows:auto auto!important; gap:3px 7px!important;
    min-height:76px!important; padding:7px 8px!important; align-items:center!important;
    overflow:hidden!important; border-radius:9px!important;
  }
  .customer-card>.customer-main { grid-column:1!important; grid-row:1!important; min-width:0!important; }
  .customer-card>.customer-stats {
    grid-column:1!important; grid-row:2!important; display:grid!important;
    grid-template-columns:repeat(2,minmax(0,1fr))!important; gap:1px 5px!important;
    min-width:0!important; margin:0!important; padding:0!important; border:0!important;
  }
  .customer-card>.customer-actions {
    grid-column:2!important; grid-row:1/3!important; display:grid!important;
    grid-template-columns:repeat(3,minmax(0,1fr))!important; align-self:center!important;
    width:112px!important; min-width:0!important; gap:2px!important; margin:0!important;
  }
  .customer-name { font-size:13px!important; line-height:1.2!important; }
  .customer-name .badge { padding:2px 5px!important; font-size:9px!important; }
  .customer-card .meta { gap:2px 7px!important; font-size:9.5px!important; line-height:1.25!important; }
  .customer-card .customer-stats span {
    min-width:0!important; overflow:hidden!important; text-overflow:ellipsis!important;
    white-space:nowrap!important; font-size:9.5px!important;
  }
  .customer-card .customer-stats span:last-child { grid-column:1/-1!important; }
  .customer-actions .icon-btn {
    display:flex!important; flex-direction:column!important; width:36px!important; min-width:36px!important;
    height:38px!important; min-height:38px!important; padding:3px 1px!important; gap:1px!important;
    border-radius:7px!important; font-size:0!important;
  }
  .customer-actions .icon-btn svg { width:14px!important; height:14px!important; }
  .customer-actions .icon-btn::after { max-width:34px!important; font-size:8px!important; line-height:1!important; }

  /* Create page: compact controls never cover product text. */
  .route-create .product-card,.route-returns .product-card {
    grid-template-columns:44px minmax(0,1fr) auto!important; min-height:66px!important;
    gap:7px!important; padding:6px 7px!important; align-items:center!important;
  }
  .route-create .product-card .product-thumb-button.catalog,.route-returns .product-card .product-thumb-button.catalog { width:44px!important; height:44px!important; }
  .route-create .product-card>div:nth-child(2),.route-returns .product-card>div:nth-child(2) { min-width:0!important; }
  .route-create .product-title,.route-returns .product-title {
    display:-webkit-box!important; overflow:hidden!important; -webkit-box-orient:vertical!important;
    -webkit-line-clamp:2!important; overflow-wrap:anywhere!important; font-size:12.5px!important;
  }
  .route-create .product-card .product-card-qty,.route-returns .product-card .product-card-qty {
    display:grid!important; grid-template-columns:30px 31px 30px!important; gap:2px!important;
    width:95px!important; max-width:95px!important; min-width:95px!important; padding:2px!important;
  }
  .create-product-column .product-card-qty button,.create-product-column .product-add-btn {
    width:30px!important; min-width:30px!important; height:30px!important; min-height:30px!important; padding:5px!important;
  }
  .create-product-column .product-card-qty .qty-input { width:31px!important; min-width:31px!important; height:30px!important; padding:0 2px!important; font-size:12px!important; }

  /* Cart: short header and exactly two rows per product. */
  .mobile-cart-sheet {
    height:min(78dvh,620px)!important; max-height:min(78dvh,620px)!important;
    grid-template-rows:12px 48px minmax(0,1fr) 58px!important;
  }
  .mobile-cart-sheet .mobile-sheet-handle { width:38px!important; height:4px!important; margin:5px auto 0!important; }
  .mobile-cart-sheet .mobile-sheet-head {
    min-height:0!important; height:48px!important; padding:4px 10px!important; gap:8px!important;
  }
  .mobile-cart-sheet .mobile-sheet-head strong { font-size:15px!important; }
  .mobile-cart-sheet .mobile-sheet-head span { font-size:10px!important; }
  .mobile-cart-sheet .mobile-sheet-head .icon-btn { width:32px!important; min-width:32px!important; height:32px!important; min-height:32px!important; }
  .mobile-cart-lines { min-height:0!important; padding:0 10px!important; overflow-y:auto!important; }
  .mobile-cart-lines .cart-line {
    display:grid!important; grid-template-columns:minmax(0,1fr) 30px!important;
    gap:5px 7px!important; padding:8px 0!important; align-items:center!important;
  }
  .mobile-cart-lines .cart-line-main { grid-column:1!important; grid-row:1!important; min-width:0!important; }
  .mobile-cart-lines .cart-line-main strong { display:block!important; overflow-wrap:anywhere!important; font-size:12px!important; line-height:1.25!important; }
  .mobile-cart-lines .cart-line-main .product-spec { font-size:9.5px!important; }
  .mobile-cart-lines .cart-line-delete { grid-column:2!important; grid-row:1!important; align-self:start!important; }
  .mobile-cart-lines .cart-line-delete .icon-btn { width:28px!important; min-width:28px!important; height:28px!important; min-height:28px!important; padding:6px!important; }
  .mobile-cart-lines .cart-line-side {
    grid-column:1/-1!important; grid-row:2!important; display:grid!important;
    grid-template-columns:minmax(88px,.9fr) auto minmax(55px,.6fr)!important;
    align-items:center!important; justify-items:stretch!important; gap:6px!important; min-width:0!important;
  }
  .mobile-cart-lines .cart-price-field { display:grid!important; grid-template-columns:auto minmax(0,1fr)!important; gap:4px!important; align-items:center!important; min-width:0!important; white-space:nowrap!important; font-size:9.5px!important; }
  .mobile-cart-lines .cart-price-input { min-width:0!important; gap:2px!important; }
  .mobile-cart-lines .cart-price-input b { font-size:10px!important; }
  .mobile-cart-lines .cart-price-field input { width:100%!important; min-width:0!important; height:30px!important; padding:0 4px!important; font-size:11px!important; }
  .mobile-cart-lines .cart-line-controls { display:grid!important; grid-template-columns:28px 30px 28px!important; gap:1px!important; padding:1px!important; }
  .mobile-cart-lines .cart-line-controls button { width:28px!important; min-width:28px!important; height:28px!important; min-height:28px!important; padding:0!important; }
  .mobile-cart-lines .cart-line-controls .qty-input { width:30px!important; min-width:30px!important; height:28px!important; padding:0 2px!important; font-size:11px!important; }
  .mobile-cart-lines .cart-line-total { min-width:0!important; overflow-wrap:anywhere!important; text-align:right!important; font-size:12px!important; }
  .mobile-cart-sheet .mobile-cart-checkout { min-height:58px!important; padding:6px 10px calc(6px + env(safe-area-inset-bottom))!important; }
  .mobile-cart-sheet .mobile-cart-checkout .btn { min-height:38px!important; }

  /* Orders: three filters always share one compact row; amount stays inside card. */
  .route-orders .order-filter-toolbar {
    display:grid!important; grid-template-columns:repeat(3,minmax(0,1fr))!important;
    gap:5px!important; margin-bottom:6px!important;
  }
  .route-orders #orderSearchInput { grid-column:1/-1!important; min-height:36px!important; height:36px!important; }
  .route-orders .order-filter-toolbar .filter-field { grid-column:auto!important; min-width:0!important; }
  .route-orders .order-filter-toolbar .filter-field:last-of-type { grid-column:auto!important; }
  .route-orders .order-filter-toolbar .filter-field label { margin-bottom:1px!important; font-size:9px!important; white-space:nowrap!important; }
  .route-orders .order-filter-toolbar .select { width:100%!important; min-width:0!important; min-height:33px!important; height:33px!important; padding:3px 18px 3px 6px!important; font-size:10.5px!important; }
  .order-card-polished .order-card-head {
    display:grid!important; grid-template-columns:minmax(0,1fr) minmax(84px,38%)!important;
    align-items:start!important; gap:5px!important;
  }
  .order-card-polished .order-card-title-row { grid-column:1!important; min-width:0!important; }
  .order-card-polished .order-card-title-row h3 { overflow-wrap:anywhere!important; font-size:13px!important; }
  .order-card-polished .order-amount,.order-card-polished .order-amount-button {
    grid-column:2!important; grid-row:1!important; justify-self:end!important; align-items:flex-end!important;
    min-width:0!important; max-width:100%!important; margin:0!important; padding:0!important;
    font-size:clamp(12px,3.6vw,17px)!important; line-height:1.1!important; text-align:right!important;
    white-space:nowrap!important; overflow:hidden!important; text-overflow:ellipsis!important;
  }
  .order-card-polished .order-card-body { padding:7px 8px!important; }
  .order-card-polished .order-card-meta-grid { gap:2px 7px!important; }
  .order-card-polished .order-icon-toolbar { min-height:32px!important; }

  /* Selected A product rows: fixed independent columns, no button intrusion. */
  .product-mobile-list { gap:4px!important; }
  .product-mobile-item {
    display:grid!important; grid-template-columns:40px minmax(0,1fr) 54px 84px!important;
    gap:4px!important; min-height:58px!important; padding:6px!important; align-items:center!important;
    overflow:hidden!important; border-radius:8px!important;
  }
  .product-mobile-item .product-thumb-button.small { grid-column:1!important; grid-row:1!important; width:40px!important; height:40px!important; }
  .product-mobile-info { grid-column:2!important; grid-row:1!important; min-width:0!important; }
  .product-mobile-info strong { font-size:12px!important; line-height:1.2!important; }
  .product-mobile-info span,.product-mobile-info small { font-size:9.5px!important; line-height:1.2!important; }
  .product-mobile-side { grid-column:3!important; grid-row:1!important; min-width:0!important; align-items:flex-end!important; }
  .product-mobile-side>strong { max-width:100%!important; overflow:hidden!important; text-overflow:ellipsis!important; font-size:13px!important; white-space:nowrap!important; }
  .product-mobile-side .badge { padding:2px 4px!important; font-size:9px!important; white-space:nowrap!important; }
  .product-mobile-item>.row-actions {
    grid-column:4!important; grid-row:1!important; display:grid!important;
    grid-template-columns:repeat(3,26px)!important; width:84px!important; min-width:84px!important;
    gap:3px!important; margin:0!important; padding:0!important; border:0!important;
  }
  .product-mobile-item>.row-actions .icon-btn {
    width:26px!important; min-width:26px!important; max-width:26px!important;
    height:30px!important; min-height:30px!important; padding:5px!important; border-radius:6px!important;
  }
  .product-mobile-select { top:1px!important; left:1px!important; width:20px!important; height:20px!important; }
}
