/* Loaded after theme styles. Screen-only rules keep document printing intact.
   ⚠ view 模組的樣式是 runtime 注入 head、排在本檔之後:同特異性會輸給它們(Opus 審查 2026-09-10),
     要壓的規則用 html 前綴拉高特異性;大字掃碼/點數輸入框(.mq-input 等)刻意排除在 16px 規則外。 */
.mobile-menu-toggle, .mobile-menu-close, .mobile-nav, .mobile-menu-backdrop { display:none; }
.mobile-filter-toggle { display:none; }
.spec-cell { display:contents; }
.spec-cell > span, .spec-mobile-label { display:none; }

@media screen and (max-width:860px) {
  body { grid-template-columns:minmax(0,1fr); overflow:hidden; }   /* 不用 :has():登入頁是 position:fixed 不受 grid 影響;不支援 :has 的引擎會整塊丟掉 */
  .main-col { width:100%; min-width:0; }
  body > .sidebar {
    position:fixed; inset:0 auto 0 0; width:min(340px,90vw); z-index:45;
    padding:calc(12px + env(safe-area-inset-top)) 14px calc(12px + env(safe-area-inset-bottom));
    visibility:hidden; transform:translateX(-100%);
  }
  .mobile-menu-open > .sidebar { visibility:visible; transform:none; }
  .mobile-menu-backdrop:not([hidden]) { display:block; position:fixed; inset:0; background:rgba(15,18,32,.5); z-index:44; }
  .sidebar .brand-name, .sidebar .nav-item span:not(.ic), .sidebar .sidebar-foot { display:block; }
  .sidebar .brand { padding-right:40px; }
  .sidebar .brand-name { font-size:16px; letter-spacing:1px; overflow-wrap:anywhere; }
  .sidebar .nav-search-wrap { display:flex !important; }
  .sidebar .nav-search-empty:not([hidden]) { display:block !important; }
  .sidebar .nav-item { min-height:46px; cursor:pointer; text-decoration:none; }
  .sidebar .nav-caret { min-width:44px; min-height:36px; text-align:center; align-content:center; }
  .sidebar .sidebar-foot { padding-top:8px; }
  .sidebar .theme-q-icons-toggle { display:none; }
  .sidebar .logout-link { display:inline-flex; align-items:center; min-height:44px; }
  .mobile-menu-close { display:block; position:absolute; top:calc(10px + env(safe-area-inset-top)); right:12px; width:44px; height:44px; border:0; border-radius:10px; background:rgba(255,255,255,.12); color:var(--side-text); font-size:20px; cursor:pointer; }
  .mobile-menu-toggle { display:block; flex:0 0 44px; height:44px; border:1px solid var(--line); border-radius:10px; background:var(--surface); color:var(--text); font-size:22px; cursor:pointer; }
  .main-col > .topbar { flex:none; flex-wrap:wrap; gap:8px; padding:calc(6px + env(safe-area-inset-top)) 12px 6px; }
  .main-col > .topbar h1 { flex:1; min-width:0; font-size:17px; overflow-wrap:anywhere; }
  .main-col > .topbar > :is(a,button) { min-height:40px; display:inline-flex; align-items:center; }
  html .main-col > .topbar .stat-strip { order:5; width:100%; margin:0; padding:6px 10px; gap:16px; flex-wrap:nowrap; overflow-x:auto; box-shadow:none; }
  .topbar .stat { flex:none; }
  .topbar .stat b { font-size:15px; }
  .mobile-nav { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); flex:none; border-top:1px solid var(--line); background:var(--surface); padding:4px env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); z-index:3; }
  .mobile-nav > :is(a,button) { display:flex; flex-direction:column; align-items:center; justify-content:center; gap:2px; min-height:54px; margin:0; padding:4px 0; border:0; border-radius:8px; text-decoration:none; background:transparent; color:var(--muted); font:inherit; font-size:11px; cursor:pointer; }
  .mobile-nav span { font-size:22px; line-height:1; }
  .mobile-nav [aria-current="page"] { color:var(--accent-strong); background:var(--accent-weak); font-weight:700; }
  .main-col > .view { min-width:0; overscroll-behavior:contain; }
  .view .toolbar, .view .toolbar-line { padding:10px 12px; gap:8px; flex-shrink:0; }
  .view .search { width:100%; min-width:0; }
  .view .search input { width:0; min-width:0; }
  .view :is(.btn,.tab), .drawer :is(.btn,.icon-btn), .modal-box .btn { min-height:44px; height:auto; white-space:normal; padding:8px 12px; }
  html .view .btn.ghost, html .drawer .btn.ghost { background:var(--surface); color:var(--text); border-color:var(--line-strong); }
  .view :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea):not(.mq-input,.oc-input,.mp-scan-input,.mp-search input,.ms-line-form input,.ms-tools input,.ms-scan input,.rc-scan input,.lg-scan input),
  .drawer :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea),
  .modal-box :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select,textarea),
  body > .sidebar :is(input:not([type=checkbox]):not([type=radio]):not([type=range]),select), #navSearch { min-height:44px; font-size:16px !important; max-width:100%; }
  .view .filters { gap:8px; }
  .view .filters > select { flex:1 1 calc(50% - 8px); min-width:0; width:0; }
  .view .chk { min-height:44px; }
  .view .tabs { flex:none; flex-wrap:nowrap; overflow-x:auto; padding:6px 12px 0; min-width:0 !important; max-width:100%; }
  .view .tabs .tab { flex:none; white-space:nowrap; }
  .view .panel { margin:10px 12px; padding:12px; min-width:0; max-width:calc(100% - 24px); overflow:auto; }
  .view .panel.flush { padding:0; }
  .view .grid-wrap { flex:1 1 auto; min-height:160px; min-width:0; max-width:100%; overscroll-behavior-x:contain; }
  .view .grid-wrap:has(table)::before { content:'↔ 左右滑動查看完整欄位'; display:block; position:sticky; left:0; width:100%; padding:6px 12px; color:var(--muted); background:var(--surface-2); font-size:12px; }
  .view :is(.grid,.table-std) { font-size:13px; }
  .view .col-name { min-width:190px; }
  /* Keep SKU, positions and prices available by scrolling the table. */
  .view :is(th,td):is(.col-price,.col-pos,.col-sku) { display:table-cell; }
  .view .pager { flex:none; padding:10px 12px; gap:8px; flex-wrap:wrap; }
  .view .pager-btns { min-width:0; max-width:100%; overflow-x:auto; }
  .view .pager-btns > * { flex-shrink:0; }
  .view .kpi-row { margin:10px 12px 0; gap:8px; }
  .view .kpi { flex:1 1 120px; min-width:0; padding:10px; }
  .view .home-wrap { padding:12px 12px 24px; min-width:0; }
  .view .home-grid { grid-template-columns:minmax(0,1fr); gap:14px; }
  .view :is(.home-col,.home-card) { min-width:0; max-width:100%; }
  .view .home-card { overflow:auto; }
  .view .home-kpi { min-width:0; padding:8px; }
  .view .home-kpi b { font-size:18px; overflow-wrap:anywhere; }
  .view .home-col h3 { flex-wrap:wrap; }
  .view .home-col h3 .sub { display:flex; align-items:center; justify-content:flex-end; gap:6px; flex-wrap:wrap; }
  .view .mobile-filter-toggle { display:flex; align-items:center; justify-content:flex-start; gap:8px; width:100%; min-height:44px; }
  .view .mobile-filter-toggle::after { content:'展開 ▾'; font-size:12px; margin-left:auto; }
  .view .mobile-filter-toggle[aria-expanded=true]::after { content:'收合 ▴'; }
  .view .mobile-filter-toggle[aria-expanded=false] + .filters { display:none; }
  html #ordBody .toolbar-line { padding:10px 12px; }
  #ordBody #mobileOrderFilters { margin:8px 12px 0; width:calc(100% - 24px); flex:none; }
  #ordBody:has(#mobileOrderFilters[aria-expanded=false]) :is(#subTabs,#chipsBar),
  #ordBody:has(#mobileOrderFilters[aria-expanded=false]) #orderToolbar > :not(#qType):not(#q):not(#searchBtn):not(#clearFilterBtn) { display:none !important; }   /* 清除篩選常駐可見 */
  .mobile-filter-toggle .mobile-filter-count { margin-left:8px; padding:2px 8px; border-radius:999px; background:var(--accent-weak); color:var(--accent-strong); font-size:12px; font-weight:700; }
  /* 接管頁(手機撿貨/手機盤點/手機模式盤點單)自己藏了 .sidebar/.topbar 且有返回鈕 → 底部 nav 一併收起(Opus 審查:「全部功能」按下去只會蓋一層遮罩) */
  body:is(.ez-mpick-full,.ez-mstock-full,.ez-mfull) .mobile-nav { display:none !important; }
  #ordBody #chipsBar > span:last-child { flex-wrap:wrap; max-width:100%; }
  #ordBody #extraDD > div { position:static !important; margin-top:8px; }
  #ordBody .toolbar-line :is(.btn,input,select), #ordBody #subTabs .btn { min-height:44px; height:auto; }
  .drawer .drawer-panel, .drawer.center .drawer-panel { width:100%; max-width:100%; height:100%; max-height:100%; border-radius:0; }
  .drawer .drawer-head, .drawer .drawer-foot { flex:none; padding:12px; gap:8px; }
  .drawer .drawer-head { padding-top:calc(10px + env(safe-area-inset-top)); }
  .drawer .drawer-foot { padding-bottom:calc(12px + env(safe-area-inset-bottom)); flex-wrap:wrap; }
  .drawer .drawer-body { min-height:0; padding:12px; overscroll-behavior:contain; }
  .drawer .field-row, .drawer .pe-itemhead { grid-template-columns:minmax(0,1fr); }
  .drawer .pe-itemhead > * { grid-column:auto !important; }
  .drawer .pe-table { min-width:720px; }
  .drawer .spec-row.spec-head { display:none; }
  .drawer .spec-row[data-row] { grid-template-columns:repeat(2,minmax(0,1fr)); padding:12px; gap:12px; border:1px solid var(--line); border-radius:10px; background:var(--surface-2); }
  .drawer .spec-cell { display:flex; flex-direction:column; gap:6px; min-width:0; }
  .drawer .spec-cell > span, .drawer .spec-mobile-label { display:block; }
  .drawer .spec-cell input { width:100%; }
  .modal-mask { padding:16px; }
  .modal-box { width:min(360px,100%); max-height:90vh; max-height:90dvh; overflow:auto; padding:18px; overflow-wrap:anywhere; }
  .modal-btns { flex-wrap:wrap; }
  .toast { bottom:calc(72px + env(safe-area-inset-bottom)); max-width:calc(100vw - 24px); width:max-content; }
  .toast-tr { right:12px; max-width:calc(100vw - 24px); }
}
/* 橫放/矮螢幕:KPI 條別固定吃掉一整列,表格與分頁器才擠得下 */
@media screen and (max-width:860px) and (max-height:560px) {
  html .main-col > .topbar .stat-strip { display:none; }
}
