/* 光采 ERP 手机 / 平板统一响应式层
   mobile-responsive-system-v1: 只改布局和触控体验，不改业务状态、权限或数据。 */

#mobileTabBar[hidden],
#mobileMoreSheet[hidden],
#mobileMoreBackdrop[hidden] {
  display: none !important;
}

/* 平板：保留折叠侧栏，减少桌面多栏挤压。 */
@media (min-width: 768px) and (max-width: 1023px) {
  main#main {
    padding: 18px 18px 104px !important;
  }

  .controls {
    padding: 12px 18px;
  }

  .today-cards,
  .today-cards-dev,
  .today-cards-po,
  body.sidebar-collapsed .today-cards,
  body.sidebar-collapsed .today-cards-dev,
  body.sidebar-collapsed .today-cards-po {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .style-grid,
  .po-grid,
  .po-arch-grid,
  .prod-grid-wrapper {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .ship-page,
  .plog-page,
  .client-info-page {
    padding-left: 18px !important;
    padding-right: 18px !important;
  }

  .ship-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .ship-cell:nth-child(3n) {
    border-right: 0;
  }

  .ship-cell:nth-child(-n + 3) {
    border-bottom: 1px solid var(--line-soft, #e5e5ea);
  }

  .ship-table-wrap,
  .admin-table-wrap,
  .qt-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .ship-table {
    min-width: 920px;
  }

  .client-info-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }
}

/* 手机：统一到 767px，不按具体手机型号写死。 */
@media (max-width: 767px) {
  :root {
    --gc-mobile-nav-height: 58px;
    --gc-mobile-page-gap: 12px;
  }

  html,
  body {
    width: 100%;
    min-width: 0;
    min-height: 100%;
    overflow-x: hidden;
    overscroll-behavior-x: none;
  }

  body.mobile-sheet-open {
    overflow: hidden !important;
    touch-action: none;
  }

  .sidebar,
  #sidebar,
  .storage-notice,
  .collapsed-flyout {
    display: none !important;
  }

  .content-area {
    width: 100% !important;
    min-width: 0 !important;
    margin-left: 0 !important;
    padding-left: 0 !important;
  }

  main#main {
    width: 100%;
    min-width: 0;
    padding: 12px 12px calc(var(--gc-mobile-nav-height) + env(safe-area-inset-bottom) + 28px) !important;
    scroll-padding-bottom: calc(var(--gc-mobile-nav-height) + env(safe-area-inset-bottom) + 24px);
    -webkit-overflow-scrolling: touch;
  }

  main#main > * {
    min-width: 0;
    max-width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* 输入框使用 16px，避免 iPhone 聚焦时自动放大页面。 */
  input,
  select,
  textarea,
  [contenteditable="true"] {
    font-size: 16px !important;
  }

  button,
  [role="button"] {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }

  main#main button,
  .drawer button,
  .modal button,
  .app-dialog button,
  .template-modal button,
  .client-info-modal button,
  .gc-cu-modal button {
    min-height: 44px;
  }

  /* 顶部搜索和筛选：一行一个职责，筛选可横向滑动。 */
  .controls {
    width: 100%;
    padding: 10px 12px;
    gap: 8px;
    align-items: stretch;
    background: var(--bg, #f5f5f7);
  }

  .controls .search {
    flex: 1 0 100%;
    width: 100%;
    min-width: 0;
    max-width: none;
  }

  .controls .search input {
    min-height: 44px;
    padding-top: 10px;
    padding-bottom: 10px;
  }

  .controls .filter-group,
  .cg-chips-row .filter-group,
  .patternlog-filters,
  .plog-facets,
  .ship-subtabs {
    max-width: 100%;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .controls .filter-group::-webkit-scrollbar,
  .cg-chips-row .filter-group::-webkit-scrollbar,
  .patternlog-filters::-webkit-scrollbar,
  .plog-facets::-webkit-scrollbar,
  .ship-subtabs::-webkit-scrollbar {
    display: none;
  }

  .filter-btn,
  .view-toggle button,
  .ship-subtab,
  .plog-chip,
  .plog-section-tab,
  .gc-sdf-chip,
  .peter-ai-brand-option {
    min-height: 44px;
    flex: 0 0 auto;
  }

  .view-toggle {
    width: 100%;
    margin-left: 0;
  }

  .view-toggle button {
    flex: 1;
  }

  .ef-date-filter,
  .show-po-toggle {
    min-height: 44px;
  }

  .erp-filter-status,
  .ship-filter-status {
    margin-left: 0;
    margin-right: 0;
  }

  /* 手机顶部只保留报警，批量入口放在“更多”里。 */
  .global-tools,
  .floating-tools {
    top: calc(8px + env(safe-area-inset-top)) !important;
    right: 10px !important;
    gap: 6px;
  }

  .global-tools .batch-toggle-btn,
  .floating-tools .batch-toggle-btn {
    display: none !important;
  }

  .alert-bell,
  .floating-btn {
    width: 42px !important;
    height: 42px !important;
  }

  .today-search-bar {
    top: 0;
    min-height: 46px;
    margin: 0 52px 10px 0 !important;
    padding: 8px 11px;
    border-radius: 9px;
  }

  .alert-panel {
    top: calc(58px + env(safe-area-inset-top));
    right: 10px !important;
    left: 10px !important;
    width: auto !important;
    max-height: calc(100dvh - 86px - var(--gc-mobile-nav-height) - env(safe-area-inset-bottom));
  }

  /* 底部导航：安全区属于导航本身，主内容同步让位。 */
  #mobileTabBar {
    display: flex !important;
    height: calc(var(--gc-mobile-nav-height) + env(safe-area-inset-bottom)) !important;
    padding: 0 4px env(safe-area-inset-bottom) !important;
    background: var(--bg-elevated, #fbfbfd) !important;
    border-top: 1px solid var(--line, #e5e5ea) !important;
    box-shadow: 0 -3px 16px rgba(20, 20, 24, 0.06);
  }

  .mtab-item {
    min-width: 0;
    min-height: var(--gc-mobile-nav-height);
    gap: 2px;
    color: var(--ink-mute, #6b6b6e);
    font-size: 10.5px;
    font-weight: 650;
  }

  .mtab-item.active {
    color: var(--apple-blue, #007aff);
  }

  .mtab-item .mtab-icon {
    width: 23px;
    height: 23px;
  }

  #mobileMoreSheet {
    bottom: calc(var(--gc-mobile-nav-height) + env(safe-area-inset-bottom)) !important;
    max-height: min(70dvh, 560px);
    overflow-y: auto;
    padding: 8px 8px calc(10px + env(safe-area-inset-bottom)) !important;
    border-radius: 16px 16px 0 0;
    background: var(--bg-elevated, #fbfbfd) !important;
  }

  .msheet-btn {
    min-height: 52px;
    padding: 12px 14px !important;
    border-radius: 10px;
    color: var(--ink, #1d1d1f) !important;
  }

  /* 今日、开发、生产、历史：单列优先。 */
  .today-page,
  .admin-wrap,
  .ship-page,
  .plog-page,
  .client-info-page,
  .patternlog-page {
    width: 100%;
    min-width: 0;
    padding: 0 0 18px !important;
  }

  .today-cards,
  .today-cards-dev,
  .today-cards-po,
  body.sidebar-collapsed .today-cards,
  body.sidebar-collapsed .today-cards-dev,
  body.sidebar-collapsed .today-cards-po {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 9px !important;
  }

  .today-card {
    min-width: 0;
    padding: 11px !important;
    gap: 10px;
  }

  .today-card .thumb-mini,
  .today-card .thumb-mini-placeholder {
    width: 52px;
    height: 66px;
  }

  .today-card-v2 .today-card-row1 {
    flex-wrap: wrap;
    gap: 5px;
  }

  .today-card-v2 .today-card-row2,
  .today-card-v2 .today-card-row3 {
    flex-wrap: wrap;
    row-gap: 3px;
  }

  .today-card-v2 .today-card-row3 .today-card-ef {
    margin-left: auto;
  }

  .admin-overview-bar,
  .cg-chips-row {
    max-width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    scrollbar-width: none;
  }

  .admin-overview-chip,
  .cg-chips-row .filter-btn {
    flex: 0 0 auto;
    min-height: 40px;
  }

  /* 开发列表：图片在左，主要信息和当前节点分两行，不再压成四小列。 */
  .list-header,
  .list-header.simplified,
  .production-list-header {
    display: none !important;
  }

  .style-list,
  .production-list {
    overflow: visible;
    border-radius: 10px;
  }

  .style-row,
  .style-row.simplified {
    display: grid !important;
    grid-template-columns: 52px minmax(0, 1fr) auto !important;
    grid-template-rows: auto auto auto !important;
    gap: 5px 9px !important;
    align-items: center !important;
    padding: 10px !important;
  }

  .style-row > .thumb,
  .style-row > .thumb-placeholder,
  .style-row.simplified > .thumb,
  .style-row.simplified > .thumb-placeholder {
    grid-column: 1 !important;
    grid-row: 1 / 4 !important;
    width: 52px !important;
    height: 68px !important;
    align-self: start !important;
  }

  .style-row > .sku,
  .style-row.simplified > .sku {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: block !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    word-break: normal !important;
    font-size: 13px !important;
    font-weight: 720 !important;
  }

  .style-row > .client-badge,
  .style-row.simplified > .client-badge {
    grid-column: 3 !important;
    grid-row: 1 !important;
    align-self: center !important;
    justify-self: end !important;
    margin: 0 !important;
  }

  .style-row > div:not(.sku):not(.client-badge):not(.thumb):not(.thumb-placeholder):not(.node-block):not(.arrow),
  .style-row.simplified > div:not(.sku):not(.client-badge):not(.thumb):not(.thumb-placeholder):not(.node-block):not(.arrow) {
    grid-column: 2 / 4 !important;
    grid-row: 2 !important;
    min-width: 0 !important;
  }

  .style-row > .node-block,
  .style-row.simplified > .node-block {
    grid-column: 2 / 4 !important;
    grid-row: 3 !important;
    min-width: 0 !important;
    margin: 0 !important;
    text-align: left !important;
  }

  .style-row .node-block-row1 {
    justify-content: flex-start !important;
  }

  .style-row .arrow,
  .production-row .arrow,
  .style-row .batch-checkbox,
  .style-row .row-batch-checkbox,
  .production-row .batch-checkbox,
  .production-row .row-batch-checkbox {
    display: none !important;
  }

  .production-row {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 7px 10px !important;
    padding: 11px !important;
    align-items: flex-start !important;
  }

  .production-row > * {
    min-width: 0;
  }

  .production-row > .thumb,
  .production-row > .thumb-placeholder {
    width: 52px !important;
    height: 68px !important;
    flex: 0 0 52px !important;
  }

  .production-row > *:not(.thumb):not(.thumb-placeholder):not(.arrow):not(.batch-checkbox):not(.row-batch-checkbox) {
    flex: 1 1 calc(50% - 10px);
  }

  /* 平铺、看板和版师档案。 */
  .style-grid,
  .po-grid,
  .po-arch-grid,
  .prod-grid-wrapper,
  .prod-board,
  .peter-ai-workbench-grid,
  .peter-ai-workbench-grid.workbench-grid-core {
    grid-template-columns: minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .style-grid,
  .po-grid {
    padding: 0 !important;
  }

  .grid-card {
    min-height: 116px;
  }

  .grid-card-img-wrap {
    width: 92px !important;
  }

  .board {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: min(82vw, 320px);
    grid-template-columns: none !important;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    padding-bottom: 8px;
  }

  .board-col {
    scroll-snap-align: start;
  }

  .plog-header {
    margin-bottom: 16px;
  }

  .plog-header-title {
    font-size: 24px;
  }

  .plog-header-stats {
    font-size: 12px;
    line-height: 1.7;
  }

  .plog-toolbar-row {
    align-items: stretch;
    flex-direction: column;
  }

  .plog-view-toggle {
    width: 100%;
    height: 44px;
  }

  .plog-view-toggle button {
    flex: 1;
    justify-content: center;
  }

  .plog-facets {
    margin-inline: -12px;
    padding-inline: 12px;
  }

  .plog-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 9px;
  }

  .plog-group {
    margin-top: 26px;
  }

  .plog-group-header {
    align-items: flex-start;
    margin-bottom: 11px;
    padding-bottom: 9px;
  }

  .plog-group-title {
    font-size: 17px;
  }

  .plog-list-row {
    grid-template-columns: 54px minmax(0, 1fr) !important;
    gap: 10px;
    padding: 9px !important;
  }

  .plog-list-thumb {
    width: 54px !important;
  }

  .plog-list-aside {
    grid-column: 1 / -1;
    min-width: 0;
  }

  /* 生产 / QC：状态入口适应宽度，业务卡片上下分层。 */
  .pq2-top {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
  }

  .pq2-st,
  .pq2-report-btn {
    width: 100%;
    min-width: 0;
    min-height: 58px;
    margin: 0;
    padding: 8px 9px;
  }

  .pq2-report-btn {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .pq2-po {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 8px 10px;
    align-items: start;
    padding: 10px;
  }

  .pq2-img {
    grid-column: 1;
    grid-row: 1;
    width: 46px;
    height: 58px;
  }

  .pq2-mid {
    grid-column: 2;
    grid-row: 1;
  }

  .pq2-right {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    min-width: 0;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .pq2-acts,
  .pq2-dual,
  .pq2-focus {
    gap: 6px;
    flex-wrap: wrap;
  }

  .pq2-btn,
  .pq2-chip {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
  }

  .pv2-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pv2-sm,
  .pv2-report-btn {
    min-width: 0;
    margin: 0;
    white-space: normal;
  }

  .pv2-sm.gap {
    display: none;
  }

  .pv2-report-btn {
    grid-column: 1 / -1;
    min-height: 44px;
  }

  .pv2-h {
    padding: 11px 12px;
    flex-wrap: wrap;
  }

  .pv2-h .why {
    flex: 1 0 100%;
    margin-left: 25px;
  }

  .pv2-body {
    padding: 10px;
  }

  .prod-arrival-grid,
  .defect-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  /* 船务：摘要分格，流水线在每张卡片内部横向滑动。 */
  .ship-title-row {
    align-items: flex-start;
    margin-bottom: 12px;
  }

  .ship-page-title {
    font-size: 19px;
  }

  .ship-report-btn {
    min-height: 44px;
    margin-left: auto;
  }

  .ship-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 12px;
    box-shadow: none;
  }

  .ship-cell {
    min-width: 0;
    min-height: 96px;
    padding: 10px;
    border-bottom: 1px solid var(--line-soft, #e5e5ea);
  }

  .ship-cell:nth-child(3n) {
    border-right: 0;
  }

  .ship-cell:nth-child(n + 4) {
    border-bottom: 0;
  }

  .ship-cell .sc-head {
    gap: 4px;
    flex-wrap: wrap;
  }

  .ship-cell .sc-mode {
    margin-left: 0;
  }

  .ship-subtabs {
    width: 100%;
    height: 44px;
  }

  .ship-search-input {
    width: 100%;
    max-width: none;
    height: 44px;
  }

  .ship-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .ship-table,
  .ship-table tbody {
    display: block;
    width: 100%;
  }

  .ship-table thead {
    display: none;
  }

  .ship-table tr.s-row {
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    gap: 8px 10px;
    width: 100%;
    margin-bottom: 10px;
    padding: 10px;
    border: 1px solid var(--line-soft, #e5e5ea);
    border-radius: 11px;
    background: var(--bg-elevated, #fbfbfd);
  }

  .ship-table tr.s-row > td {
    display: block;
    padding: 0;
    border: 0;
    min-width: 0;
  }

  .ship-table tr.s-row > td:nth-child(1) {
    grid-column: 1;
    grid-row: 1;
  }

  .ship-table tr.s-row > td:nth-child(2) {
    grid-column: 2;
    grid-row: 1;
  }

  .ship-table tr.s-row > td:nth-child(3),
  .ship-table tr.s-row > td:nth-child(4) {
    grid-column: 1 / -1;
  }

  .ship-row-thumb {
    width: 46px;
    height: 58px;
  }

  .ship-stage-bar-wrap {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
  }

  .ship-stage-bar,
  .ship-phase-row {
    min-width: 520px;
  }

  .ship-action-btn {
    min-height: 44px;
    width: 100%;
    justify-content: center;
  }

  .ship-month-row,
  .ship-month-row td {
    display: block;
    width: 100%;
  }

  .ship-month-head {
    padding: 11px 10px;
  }

  /* AI 工作台：所有双栏 / 三栏变单栏，但页面仍在工作台内部滚动。 */
  body.peter-ai-workbench-active main#main,
  body.sample-dispatch-active main#main {
    height: calc(100dvh - var(--gc-mobile-nav-height) - env(safe-area-inset-bottom));
    min-height: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .peter-ai-workbench-page {
    height: 100%;
    min-height: 0;
    padding: 12px 12px 10px;
    overflow: hidden;
  }

  .peter-ai-workbench-hero {
    gap: 8px;
    margin-bottom: 10px;
    padding-bottom: 10px;
    align-items: flex-start;
    flex-direction: column;
  }

  .peter-ai-workbench-title {
    font-size: 21px;
  }

  .peter-ai-workbench-sub {
    font-size: 12px;
    margin-top: 3px;
  }

  .peter-ai-workbench-safe {
    width: 100%;
    max-width: none;
    padding: 7px 9px;
  }

  .peter-ai-workbench-layout {
    flex: 1;
    overflow-y: auto;
    padding-right: 0;
  }

  .peter-ai-workbench-card {
    min-height: 118px;
    padding: 13px;
    box-shadow: none;
  }

  .peter-ai-workbench-icon {
    width: 38px;
    height: 38px;
    margin-bottom: 9px;
  }

  .peter-ai-grid,
  .peter-ai-two,
  .peter-ai-new-layout,
  .peter-ai-form-grid,
  .peter-ai-editor-row,
  .pet-mail-field-grid,
  .pet-mail-line-grid,
  .qt-confirm-grid,
  .qt-param-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .quote-tool-page,
  .pet-mail-page {
    height: 100%;
    min-height: 0;
    overflow-y: auto;
    padding: 8px;
  }

  .quote-tool-page,
  .pet-mail-shell {
    display: flex;
    flex-direction: column;
    gap: 9px;
  }

  .qt-sidebar,
  .qt-main,
  .qt-summary,
  .pet-mail-panel,
  .pet-mail-compose {
    width: 100%;
    min-height: 0;
  }

  .qt-style-list {
    max-height: 280px;
  }

  .qt-step-tabs {
    grid-template-columns: repeat(3, minmax(112px, 1fr)) !important;
    overflow-x: auto;
  }

  .qt-table-wrap,
  .pet-mail-preview-wrap,
  .pet-mail-edit-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .qt-cost-table,
  .pet-mail-edit-table,
  .pet-mail-preview table {
    min-width: 680px;
  }

  /* 寄样表：固定一屏，上半设置、下半预览，各自滚动。 */
  .sample-dispatch-page {
    height: 100%;
    min-height: 0;
    padding: 10px 10px 8px !important;
    overflow: hidden !important;
  }

  .sample-dispatch-head {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
  }

  .sample-dispatch-head h1 {
    font-size: 19px;
  }

  .sample-dispatch-head p,
  .sample-dispatch-eyebrow,
  .sample-dispatch-pill {
    display: none;
  }

  .sample-dispatch-shell {
    min-height: 0;
    height: 100%;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(260px, 46%) minmax(0, 54%);
    gap: 8px;
    overflow: hidden;
  }

  .sample-dispatch-page .gc-sdf-left,
  .sample-dispatch-page .gc-sdf-right {
    min-height: 0 !important;
    height: auto !important;
    max-height: none !important;
    overflow: hidden !important;
    border-radius: 10px;
  }

  .sample-dispatch-page .gc-sdf-left {
    padding: 10px;
  }

  .sample-dispatch-page .gc-sdf-left-head {
    margin-bottom: 8px;
  }

  .sample-dispatch-page .gc-sdf-panels,
  .sample-dispatch-page .gc-sdf-panel.on,
  .sample-dispatch-page .gc-sdf-style-panel .gc-sdf-list,
  .sample-dispatch-page .gc-sdf-dear-list {
    min-height: 0;
    max-height: none !important;
  }

  .sample-dispatch-page .gc-sdf-style-panel .gc-sdf-list,
  .sample-dispatch-page .gc-sdf-dear-list,
  .sample-dispatch-page .gc-sdf-panel:not(.gc-sdf-style-panel) {
    overflow-y: auto;
  }

  .sample-dispatch-page .gc-sdf-toolbar {
    min-height: 48px;
    padding: 8px 10px;
  }

  .sample-dispatch-page .gc-sdf-preview {
    min-height: 0;
    padding: 8px;
  }

  .sample-dispatch-page .gc-sdf-paper {
    transform: none !important;
    width: 210mm;
    min-width: 210mm;
    margin: 0 !important;
  }

  .gc-sdf-print-btn {
    min-height: 40px;
    padding: 8px 12px;
  }

  /* 客户邮件工具抽屉。 */
  .gc-cu-drawer {
    width: 100%;
    height: 100dvh;
    grid-template-columns: minmax(0, 1fr) !important;
    grid-template-rows: minmax(220px, 46%) minmax(0, 54%);
  }

  .gc-cu-left,
  .gc-cu-right {
    min-height: 0;
    max-height: none !important;
    overflow-y: auto;
  }

  .gc-cu-right {
    padding: 12px;
  }

  .gc-cu-close-float {
    width: 44px;
    height: 44px;
    top: calc(6px + env(safe-area-inset-top));
    right: 8px;
  }

  .gc-cu-ebox {
    min-height: 260px;
    max-height: none;
    padding: 14px;
  }

  .gc-cu-mail-meta {
    grid-template-columns: 52px minmax(0, 1fr);
  }

  /* 客户信息。 */
  .client-info-header {
    gap: 16px;
    margin-bottom: 16px;
  }

  .client-info-title h1 {
    font-size: 24px !important;
  }

  .client-info-title p {
    font-size: 13px;
  }

  .client-info-brand-grid,
  .client-info-cards,
  .client-info-list,
  .client-info-workspace {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .client-info-group-rail {
    position: static;
    padding: 6px;
  }

  .client-info-list {
    display: flex !important;
    flex-direction: row;
    overflow-x: auto;
    gap: 6px;
    scrollbar-width: none;
  }

  .client-info-list > * {
    flex: 0 0 auto;
  }

  .client-contact-card {
    padding: 15px !important;
  }

  .client-info-modal-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .client-info-modal {
    width: 100%;
    max-height: 92dvh;
    border-radius: 16px 16px 0 0;
  }

  .client-info-form {
    grid-template-columns: minmax(0, 1fr) !important;
    padding: 16px;
  }

  /* 管理后台。 */
  .admin-page-head {
    gap: 12px;
    margin-bottom: 14px;
  }

  .admin-sec {
    padding: 13px !important;
    border-radius: 11px;
  }

  .admin-storage-grid,
  .admin-storage-split {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .admin-storage-card {
    padding: 12px;
  }

  .admin-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .admin-tbl {
    min-width: 760px;
  }

  .admin-filterbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
  }

  .admin-filterbar input,
  .admin-filterbar select {
    width: 100%;
    max-width: none;
    min-height: 44px;
  }

  /* 抽屉：手机全屏，操作按钮固定在拇指区域。 */
  .drawer {
    top: 0;
    right: 0;
    width: 100vw;
    max-width: none;
    height: 100dvh;
    border-radius: 0;
  }

  .drawer-header {
    flex: 0 0 auto;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px;
    gap: 10px;
  }

  .drawer-title h2 {
    font-family: var(--font-sans);
    font-size: 20px;
    font-weight: 760;
  }

  .drawer-desc {
    font-size: 12px;
  }

  .drawer-close {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
  }

  .drawer-body {
    min-height: 0;
    padding: 0 14px 22px;
    overscroll-behavior: contain;
  }

  .drawer-status-actions {
    margin-left: -14px;
    margin-right: -14px;
  }

  .drawer-actions {
    flex: 0 0 auto;
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
    gap: 7px;
    max-height: 34dvh;
    overflow-y: auto;
  }

  .drawer-actions button {
    flex: 1 1 calc(50% - 7px);
    min-height: 44px;
    padding: 9px 10px;
  }

  .detail-top-section,
  .po-fields-section,
  .fit-comment-section,
  .spec-block,
  .notes-section {
    min-width: 0;
    padding-left: 12px !important;
    padding-right: 12px !important;
  }

  /* 弹窗：手机底部面板，表单单列。 */
  .modal-backdrop,
  .app-dialog-backdrop,
  .template-modal-backdrop,
  .add-color-backdrop {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  .modal,
  .app-dialog,
  .template-modal,
  .gc-cu-modal {
    width: 100% !important;
    max-width: none !important;
    max-height: 92dvh !important;
    border-radius: 16px 16px 0 0 !important;
  }

  .modal-header,
  .app-dialog-header,
  .template-modal-head {
    padding: 15px 16px 12px !important;
  }

  .modal-header h3 {
    font-family: var(--font-sans);
    font-size: 19px;
    font-style: normal;
    font-weight: 760;
  }

  .modal-body,
  .app-dialog-body,
  .template-modal-body {
    padding: 14px 16px !important;
  }

  .modal-footer,
  .app-dialog-footer,
  .template-modal-foot {
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom)) !important;
  }

  .modal-footer button,
  .app-dialog-footer button,
  .template-modal-foot button {
    flex: 1;
    min-height: 44px;
    padding: 9px 10px;
  }

  /* feedback-modal-centered-v2: 客户评语即使在窄屏也保持居中圆角，不沿用通用底部面板。 */
  #updateBackdrop.feedback-drawer {
    align-items: center !important;
    justify-content: center !important;
    padding: 12px !important;
  }

  #updateBackdrop.feedback-drawer .modal {
    width: calc(100vw - 24px) !important;
    max-width: 620px !important;
    height: min(840px, calc(100dvh - 24px)) !important;
    max-height: calc(100dvh - 24px) !important;
    margin: 0 !important;
    border-radius: 18px !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
  }

  #updateBackdrop.feedback-drawer .modal-header {
    flex: 0 0 auto;
    position: static;
    border-radius: 18px 18px 0 0;
  }

  #updateBackdrop.feedback-drawer .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #updateBackdrop.feedback-drawer .modal-footer {
    flex: 0 0 auto;
    position: static;
    padding-bottom: 10px !important;
    border-radius: 0 0 18px 18px;
  }

  /* QC 登记弹窗：标题 / 操作固定，只让中间表单滚动，并避开手机底部导航。 */
  #updateBackdrop.gc-prod-qc-modal .modal {
    height: min(92dvh, calc(100dvh - var(--gc-mobile-nav-height) - env(safe-area-inset-bottom))) !important;
    max-height: calc(100dvh - var(--gc-mobile-nav-height) - env(safe-area-inset-bottom)) !important;
    margin-bottom: calc(var(--gc-mobile-nav-height) + env(safe-area-inset-bottom));
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
  }

  #updateBackdrop.gc-prod-qc-modal .modal-header {
    flex: 0 0 auto;
    position: static;
  }

  #updateBackdrop.gc-prod-qc-modal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }

  #updateBackdrop.gc-prod-qc-modal .modal-footer {
    flex: 0 0 auto;
    position: static;
    padding-bottom: 10px !important;
  }

  .form-row,
  .form-row-3,
  .po-color-card-fields,
  .bf-row,
  .batch-modal-row {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .form-row,
  .form-row-3,
  .po-color-card-fields {
    gap: 10px;
  }

  .field-with-action {
    grid-template-columns: minmax(0, 1fr) 44px;
  }

  .image-dropzone {
    padding: 18px 12px;
  }

  /* 批量操作栏高于底部导航，按钮横向滑动。 */
  .batch-bar {
    left: 8px;
    right: 8px;
    bottom: calc(var(--gc-mobile-nav-height) + env(safe-area-inset-bottom) + 8px) !important;
    width: auto !important;
    max-height: 46dvh;
    padding: 9px 10px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .batch-bar-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }

  .batch-bar-actions .batch-btn {
    flex: 0 0 auto;
    min-height: 42px;
  }

  /* 报表保持纸张比例，通过预览区域横向滚动，不压缩小字。 */
  #gcQcReportPreview .gc-rpt-shell,
  #gcProdArrivalReportPreview .gc-rpt-shell,
  #gcShippingReportPreview .gc-rpt-shell {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  #gcQcReportPreview .gc-rpt-topbar,
  #gcProdArrivalReportPreview .gc-rpt-topbar,
  #gcShippingReportPreview .gc-rpt-topbar {
    max-height: 42dvh;
    padding: 12px;
    overflow-y: auto;
  }

  #gcQcReportPreview .gc-rpt-stage,
  #gcProdArrivalReportPreview .gc-rpt-stage,
  #gcShippingReportPreview .gc-rpt-stage {
    padding: 10px !important;
    overflow: auto !important;
  }

  #gcQcReportPreview .gc-rpt-sheet,
  #gcQcReportPreview .gc-qcrpt-appendix-page,
  #gcProdArrivalReportPreview .gc-rpt-sheet,
  #gcShippingReportPreview .gc-rpt-sheet {
    width: 960px !important;
    min-width: 960px !important;
    margin: 0 !important;
  }

  /* 打印预览工具栏保留核心操作，纸张区域允许横向查看。 */
  .print-spec-toolbar {
    padding: 8px 10px;
  }

  .print-spec-actions {
    overflow-x: auto;
  }

  .print-spec-btn {
    min-height: 40px;
    padding: 7px 10px;
    white-space: nowrap;
  }

  .print-spec-scroll {
    overflow: auto;
    padding: 10px;
  }

  .print-spec-paper {
    width: 210mm !important;
    min-width: 210mm;
    min-height: 297mm;
    padding: 14mm 16mm !important;
    margin: 0 !important;
  }
}

/* 普通小屏手机：摘要两列，卡片更重视文字宽度。 */
@media (max-width: 430px) {
  .ship-strip,
  .pq2-top,
  .admin-storage-grid,
  .admin-storage-split {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  }

  .ship-cell:nth-child(3n) {
    border-right: 1px solid var(--line-soft, #e5e5ea);
  }

  .ship-cell:nth-child(2n) {
    border-right: 0;
  }

  .ship-cell:nth-child(n + 4) {
    border-bottom: 1px solid var(--line-soft, #e5e5ea);
  }

  .ship-cell:nth-child(n + 5) {
    border-bottom: 0;
  }

  .peter-ai-workbench-card span,
  .peter-ai-workbench-guide,
  .peter-ai-workbench-section-head span {
    font-size: 12px;
  }

  .gc-sdf-toolbar-sub {
    display: none;
  }
}

/* 极小屏：避免两列信息继续挤压。 */
@media (max-width: 360px) {
  :root {
    --gc-mobile-page-gap: 10px;
  }

  main#main {
    padding-left: 10px !important;
    padding-right: 10px !important;
  }

  .plog-grid,
  .admin-storage-grid,
  .admin-storage-split {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .grid-card-img-wrap {
    width: 82px !important;
  }

  .mtab-item {
    font-size: 10px;
  }

  .mtab-item .mtab-icon {
    width: 21px;
    height: 21px;
  }

  .drawer-actions button {
    flex-basis: 100%;
  }
}

/* 横屏手机：工作台改为左右结构，提高有效操作面积。 */
@media (max-width: 767px) and (orientation: landscape) {
  .sample-dispatch-shell {
    grid-template-columns: minmax(280px, 42%) minmax(0, 58%) !important;
    grid-template-rows: minmax(0, 1fr);
  }

  .gc-cu-drawer {
    grid-template-columns: minmax(300px, 44%) minmax(0, 56%) !important;
    grid-template-rows: minmax(0, 1fr);
  }

  .sample-dispatch-head {
    display: none;
  }

  .drawer-actions {
    max-height: 42dvh;
  }
}

/* iPhone real-device correction v2: desktop menu parity + compact filters + dev row fix. */
#mobileFilterToggle {
  display: none;
}

@media (max-width: 767px) {
  #controlsBar.mobile-controls-visible {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 70px 46px;
    align-items: center;
    gap: 8px;
    padding: 9px 10px;
  }

  #controlsBar > .search {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    min-width: 0;
    max-width: none;
    flex: none;
  }

  #controlsBar > .search input {
    min-height: 44px;
    padding-right: 10px;
  }

  #mobileFilterToggle {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    min-height: 44px;
    padding: 0 9px;
    border: 1px solid var(--line-strong, #d1d1d6);
    border-radius: 9px;
    background: var(--bg-elevated, #fbfbfd);
    color: var(--ink-soft, #424248);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
  }

  #mobileFilterToggle svg {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
  }

  #mobileFilterToggle.active {
    border-color: var(--apple-blue, #007aff);
    background: var(--apple-blue-bg, #e5f0ff);
    color: var(--apple-blue, #007aff);
  }

  #controlsBar > :not(.search):not(#mobileFilterToggle) {
    grid-column: 1 / -1;
    min-width: 0;
    max-width: 100%;
  }

  body:not(.mobile-filters-open) #controlsBar > :not(.search):not(#mobileFilterToggle) {
    display: none !important;
  }

  body.mobile-filters-open #controlsBar {
    padding-bottom: 11px;
  }

  body.mobile-filters-open #controlsBar > .filter-group,
  body.mobile-filters-open #controlsBar > .view-toggle,
  body.mobile-filters-open #controlsBar > .ef-date-filter,
  body.mobile-filters-open #controlsBar > .show-po-toggle {
    margin: 0;
  }

  body[data-mobile-route="dev"]:not(.mobile-filters-open) .cg-chips-row,
  body[data-mobile-route="production"]:not(.mobile-filters-open) .cg-chips-row,
  body[data-mobile-route="archive-done"]:not(.mobile-filters-open) .cg-chips-row,
  body[data-mobile-route="archive-archived"]:not(.mobile-filters-open) .cg-chips-row {
    display: none !important;
  }

  .erp-filter-status {
    min-height: 36px;
    margin: 0 10px 8px;
    padding: 7px 9px;
    gap: 6px;
    font-size: 11.5px;
  }

  .erp-filter-chip {
    height: 20px;
    padding: 0 7px;
    font-size: 11px;
  }

  .msheet-section-title {
    padding: 7px 10px 6px;
    color: var(--ink-mute, #6b6b6e);
    font-size: 11px;
    font-weight: 750;
  }

  .msheet-nav-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
    padding: 0 6px 6px;
  }

  .msheet-nav-btn {
    min-width: 0;
    min-height: 54px;
    padding: 9px 10px;
    border: 1px solid var(--line, #e5e5ea);
    border-radius: 10px;
    background: var(--bg-elevated, #fbfbfd);
    color: var(--ink, #1d1d1f);
    display: flex;
    align-items: center;
    gap: 9px;
    text-align: left;
    font: inherit;
    cursor: pointer;
  }

  .msheet-nav-btn.active {
    border-color: var(--apple-blue, #007aff);
    background: var(--apple-blue-bg, #e5f0ff);
    color: var(--apple-blue, #007aff);
  }

  .msheet-nav-btn .mtab-icon {
    width: 21px;
    height: 21px;
    flex: 0 0 auto;
  }

  .msheet-nav-text {
    min-width: 0;
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
  }

  .msheet-nav-text b {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12.5px;
  }

  .msheet-nav-text em {
    margin-left: auto;
    min-width: 22px;
    height: 20px;
    padding: 0 6px;
    border-radius: 8px;
    background: var(--bg-sunken, #ebebef);
    color: var(--ink-soft, #424248);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10.5px;
    font-style: normal;
    font-weight: 750;
  }

  /* 开发追踪真实 DOM 有 style-row-brand-info，单独重排，避免旧四列规则撑出空白。 */
  .style-row.simplified.dev-list-row {
    min-height: 0 !important;
    height: auto !important;
    grid-template-columns: 62px minmax(0, 1fr) !important;
    grid-template-rows: auto auto auto !important;
    align-content: start !important;
    align-items: start !important;
    gap: 5px 10px !important;
    padding: 10px !important;
  }

  .style-row.simplified.dev-list-row > .batch-checkbox,
  .style-row.simplified.dev-list-row > .row-batch-checkbox,
  .style-row.simplified.dev-list-row > .arrow {
    display: none !important;
  }

  .style-row.simplified.dev-list-row > .thumb,
  .style-row.simplified.dev-list-row > .thumb-placeholder {
    grid-column: 1 !important;
    grid-row: 1 / 4 !important;
    width: 62px !important;
    height: 80px !important;
    align-self: start !important;
  }

  .style-row.simplified.dev-list-row > .sku {
    grid-column: 2 !important;
    grid-row: 1 !important;
    display: block !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
    font-size: 13px !important;
    font-weight: 760 !important;
    line-height: 1.35 !important;
  }

  .style-row.simplified.dev-list-row > .style-row-brand-info {
    grid-column: 2 !important;
    grid-row: 2 !important;
    min-width: 0 !important;
    width: 100%;
    display: flex !important;
    flex-direction: column;
    align-items: flex-start !important;
    gap: 5px !important;
  }

  .style-row.simplified.dev-list-row > .style-row-brand-info .client-badge {
    max-width: 100% !important;
    min-height: 22px;
    padding: 2px 7px !important;
    font-size: 10.5px !important;
  }

  .style-row.simplified.dev-list-row > .style-row-brand-info .style-row-info {
    width: 100%;
    min-width: 0;
    gap: 3px;
  }

  .style-row.simplified.dev-list-row > .style-row-brand-info .style-name {
    max-height: 42px;
    overflow: hidden;
    gap: 4px !important;
  }

  .style-row.simplified.dev-list-row > .style-row-brand-info .style-subinfo {
    gap: 5px !important;
    font-size: 10.5px !important;
  }

  .style-row.simplified.dev-list-row > .node-block {
    grid-column: 2 !important;
    grid-row: 3 !important;
    min-width: 0 !important;
    width: 100%;
    margin: 0 !important;
    text-align: left !important;
  }

  .style-row.simplified.dev-list-row > .node-block .node-block-row1 {
    justify-content: flex-start !important;
    flex-wrap: nowrap !important;
  }
}

@media print {
  #mobileTabBar,
  #mobileMoreSheet,
  #mobileMoreBackdrop {
    display: none !important;
  }
}
