/* Mobile readability scale: keep dense business screens readable without changing desktop. */
/* Mobile notices keep their message and dismissal behavior without a countdown label. */
.android-native-shell #noticeCountdown { display: none; }

@media (max-width: 900px) {
  html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
  body { font-size: 15px; line-height: 1.5; }

  .brand-story-trigger .brand-spanish-name { font-size: 10px !important; }
  .brand-tagline span { font-size: 11px !important; line-height: 1.2; }
  .header-pos-sync .header-surface-username,
  .header-pos-sync .header-database-label,
  .header-pos-sync .pos-client-meta,
  .management-surface-badge small,
  .client-surface-badge small { font-size: 10px !important; line-height: 1.25; }
  .header-pos-sync .pos-sync-status { font-size: 11px !important; line-height: 1.3; }
  /* Keep the connection result readable inside the small jade status plaque. */
  #clientSurfaceBadgeConnection {
    overflow: visible;
    font-size: clamp(8px, 2.3vw, 9px) !important;
    line-height: 1.15 !important;
    letter-spacing: 0;
    text-overflow: clip;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  main h1 { font-size: 24px !important; line-height: 1.2; }
  main h2,
  main .panel h2,
  main .sales-report-heading h2,
  main .sales-report-heading-compact h2,
  main .reference-source-heading h2,
  main .rate-compact h2 { font-size: 21px !important; line-height: 1.25; }
  main h3,
  main .rate-compact h3,
  main .cross-v236-process h3,
  main .cross-v236-used h3,
  main .cross-v236-sources h3 { font-size: 17px !important; line-height: 1.3; }
  main h4,
  main .reference-user-section-heading h4 { font-size: 15px !important; line-height: 1.35; }

  main :is(p, li, dt, dd) { font-size: 14px; line-height: 1.5; }
  main :is(label, legend, summary) { font-size: 13px; line-height: 1.4; }
  main :is(button, .button, input, select, textarea) {
    font-size: 14px !important;
    line-height: 1.3;
  }

  /* 手机端询价的查找与扫码是并列入口：按钮、文字和图标保持完全同尺寸。 */
  #priceSearch #globalSearchButton,
  #priceSearch #openBarcodeScanner {
    min-height: 69px !important;
    padding: 12px 18px !important;
    gap: 10.5px;
    font-size: 21px !important;
  }
  #priceSearch #globalSearchButton .ui-action-icon,
  #priceSearch #openBarcodeScanner .ui-action-icon {
    width: 33px;
    height: 33px;
    border-radius: 10.5px;
    font-size: 16.5px;
  }
  main :is(table, th, td) { font-size: 13px !important; line-height: 1.35; }
  main small,
  main time,
  main .muted,
  main [role="status"] { font-size: 12px !important; line-height: 1.45; }

  body > dialog h2 { font-size: 21px !important; line-height: 1.25; }
  /* 收银销售明细的单号缩小 30%，不影响其他弹窗标题。 */
  #outageReceiptDetailTitle { font-size: 14.7px !important; font-size: min(14.7px,6.4cqi) !important; }
  body > dialog h3 { font-size: 17px !important; line-height: 1.3; }
  body > dialog h4 { font-size: 15px !important; line-height: 1.35; }
  body > dialog :is(p, li) { font-size: 14px; line-height: 1.5; }
  body > dialog :is(button, .button, input, select, textarea) { font-size: 14px !important; line-height: 1.3; }
  body > dialog :is(table, th, td) { font-size: 13px !important; line-height: 1.35; }
  body > dialog :is(small, time, .muted, [role="status"]) { font-size: 12px !important; line-height: 1.45; }

  .tabs .tab,
  .management-subnav .management-subtab { font-size: 13px !important; }
  .tabs .tab > span:last-child,
  .management-subtab > span:last-child { font-size: inherit !important; }

  /* 报表四个子页签与工具页尺寸统一；卡片高度随字号和内边距自适应。 */
  #salesSubnav {
    min-height: 0;
    height: auto;
  }
  #salesSubnav .management-subtab {
    min-height: 42px;
    height: auto;
    padding: 5px 4px;
    font-size: 13px !important;
    line-height: 1.2;
  }
  #salesSubnav .management-subtab > span:last-child {
    font-size: 13px !important;
    line-height: 1.2;
  }

  /* Query and compact mobile tables. */
  .inquiry-table-settings-button,
  .inquiry-table[data-sort-table="market"] thead th,
  .inquiry-table[data-sort-table="supplier"] thead th,
  .table-price-label { font-size: 12px !important; }
  .inquiry-table[data-sort-table="market"] thead th {
    overflow-wrap: anywhere;
    white-space: normal !important;
  }
  .inquiry-table[data-sort-table="market"] thead .mobile-sort-label {
    white-space: normal;
  }
  .sales-report-table td::before,
  #salesDocumentsTable td::before,
  #salesDetailsTable td::before,
  #payroll .payroll-attendance-table td::before { font-size: 12px !important; line-height: 1.2; }
  #salesDocumentsTable .sales-document-open-hint,
  #salesDetailsTable code { font-size: 12px !important; }
  .sales-date-shortcuts button,
  .sales-selected-document button,
  .sales-report-heading-actions button,
  .sales-report-pagination button { font-size: 13px !important; }

  /* 商品卡片底部的更新时间和条码保持紧凑，避免长数字在窄屏互相覆盖。 */
  .inquiry-table[data-sort-table="market"] tbody .market-updated-column,
  .inquiry-table[data-sort-table="market"] tbody .market-barcode-column {
    min-width: 0;
    padding-inline: 4px;
    font-size: 9px !important;
    line-height: 1.15;
    letter-spacing: -.015em;
    white-space: nowrap;
  }
  .inquiry-table[data-sort-table="market"] tbody :is(.market-updated-column,.market-barcode-column)::before {
    margin-right: 3px;
    font-size: 8px !important;
    line-height: 1.1;
  }

  /* Chart labels and legends must remain legible at 390px. */
  .sales-trend-labels text,
  .sales-comparison-labels text,
  .sales-comparison-y-labels text,
  .sales-trend-tooltip text,
  .sales-comparison-tooltip text,
  .sales-trend-maximum,
  .sales-comparison-count { font-size: 12px !important; }
  .sales-trend-card p,
  .sales-comparison-card p,
  .sales-comparison-legend,
  .sales-comparison-legend :is(b, em, small) { font-size: 12px !important; line-height: 1.4; }

  /* Exchange-rate compact mode previously reduced text to 7–10px. */
  .rate-compact :is(p, label) { font-size: 13px !important; }
  .rate-compact :is(small, time),
  .rate-compact .dolar-hoy-refresh-area span,
  .rate-compact .yuan-rate-refresh-area > span,
  .rate-compact .cross-rate-refresh-area span,
  .rate-compact .cross-v236-note,
  .rate-compact .cross-v236-process > p,
  .rate-compact .cross-route-breakdown p,
  .rate-compact .cross-source-note,
  .rate-compact .dolar-hoy-source-note,
  .rate-compact .yuan-source-note { font-size: 12px !important; line-height: 1.4; }
  .rate-compact .dolar-currency-toggle button,
  .rate-compact .yuan-currency-toggle button,
  .rate-compact .cross-v236-currency-toggle button,
  .rate-compact .cross-yuan-market button,
  .rate-compact .rate-refresh-button,
  .rate-compact .dolar-hoy-refresh,
  .rate-compact .yuan-rate-refresh { font-size: 13px !important; }
  .rate-compact .exchange-source-option strong,
  .rate-compact .yuan-source-option strong { font-size: 14px !important; }
  /* Long rate labels must remain inside their buttons and heading columns. */
  #rateSubnav .management-subtab {
    white-space: normal;
  }
  #rateSubnav .management-subtab > span:last-child {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  #dolarHoy #dolarHoyTitle,
  #renminbiRate #yuanRateTitle {
    min-width: 0;
    max-width: 100%;
    font-size: clamp(15px, 4.7vw, 20px) !important;
    line-height: 1.2;
    overflow-wrap: anywhere;
    white-space: normal;
  }
  #dolarHoy .dolar-calculator-results .dolar-result-heading > .dolar-result-fee-note {
    min-width: 0;
    font-size: clamp(9px, 1.45vw, 11px) !important;
    line-height: 1.2;
    overflow-wrap: anywhere;
    white-space: normal;
  }

  /* Salary, payroll and calendar dense labels. */
  .salary-page :is(p, label),
  .payroll-page :is(p, label) { font-size: 13px; }
  .salary-page :is(small, time, em),
  .payroll-page :is(small, time, em) { font-size: 12px !important; line-height: 1.4; }
  .salary-scheme-card label b,
  .salary-scheme-card label strong,
  .salary-presentismo-controls > article span,
  .salary-selected-result span,
  .payroll-period-grid label > span,
  .payroll-dense-grid label > span,
  .payroll-employee-form-grid label > span,
  .payroll-weekday-rule legend,
  .payroll-bulk-bar label { font-size: 12px !important; }
  #payroll .payroll-attendance-table :is(select, input) { font-size: 13px !important; }
  .payroll-workspace-toolbar button,
  .payroll-employee-list article button,
  .payroll-bulk-bar button { font-size: 13px !important; }
  .calendar-event-pill,
  .calendar-event-more,
  .calendar-list-item time small,
  .calendar-legend,
  .calendar-credential-overview-heading p,
  .calendar-duration-field output { font-size: 12px !important; line-height: 1.35; }
  .calendar-heading-actions button,
  .calendar-manage-actions button { font-size: 13px !important; }

  /* 收银设置顶部的数据状态保持紧凑，不影响其他状态提示。 */
  #outageSettingsDataStatus strong { font-size: 10px !important; }
  #outageSettingsDataStatus small { font-size: 9px !important; }

  /* Settings, user permissions and explanatory copy. */
  .account-hub-page :is(p, li),
  .database-access-card p,
  .account-connection-guide span,
  .reference-sharing-card p,
  .reference-source-toolbar p { font-size: 13px !important; line-height: 1.5; }
  .account-hub-page small,
  .database-access-item small,
  .database-subsection-header p,
  .reference-user-meta,
  .reference-user-section-heading p,
  .reference-user-relationship span,
  .reference-source-unavailable small,
  .user-usage-summary,
  .terminal-session-item :is(code, em) { font-size: 12px !important; line-height: 1.4; }
  .reference-user-permissions label,
  .user-feature-choice,
  .database-access-actions :is(button, .button-link) { font-size: 13px !important; }

  /* Independent checkout: retain compact layout, raise only unreadable copy. */
  .outage-checkout-dialog,
  .outage-dialog { font-size: 13px; }
  .outage-checkout-dialog-bar,
  .outage-barcode-form label,
  .outage-toolbar > button,
  .outage-barcode-form button,
  .outage-selected-actions button,
  .outage-summary button,
  .outage-receipts summary,
  .outage-help-body,
  .outage-dialog label span,
  .outage-dialog footer button { font-size: 12px !important; }
  .outage-data-status,
  .outage-message,
  .outage-empty,
  .outage-cart-item small,
  .outage-cart-item .outage-line-money span,
  .outage-source-pill,
  .outage-summary > div span,
  .outage-speech-controls small,
  .outage-receipt-row small,
  .outage-dialog header small,
  .outage-help-dialog header small { font-size: 11px !important; line-height: 1.35; }
  .outage-cart-item h4,
  .outage-summary > div strong,
  .outage-receipt-row strong { font-size: 13px !important; }
  .outage-summary #outageTotalAmount { font-size: 21px !important; }

  /* 商品编辑器的“最近销量”是紧凑核对区，单独缩小文字且不影响下方商品表单与价格。 */
  #posSalesPanel .pos-sales-heading h3 { font-size: 14px !important; line-height: 1.15; }
  #posSalesPanel .pos-recent-sales-heading-actions > button,
  #posSalesPanel .pos-sales-range-control,
  #posSalesPanel .pos-sales-range-control select,
  #posSalesPanel .pos-sales-custom :is(label, button, input),
  #posSalesPanel .pos-recent-sales-help summary { font-size: 11px !important; line-height: 1.25; }
  #posSalesPanel .pos-sales-summary small { font-size: 10px !important; line-height: 1.2; }
  #posSalesPanel .pos-sales-summary strong { font-size: 16px !important; line-height: 1.05; }
  #posSalesPanel .pos-recent-sales-table :is(th, td) { font-size: 11px !important; line-height: 1.3; }
  #posSalesPanel .pos-sales-status { font-size: 10px !important; line-height: 1.35; }
  #posSalesPanel .pos-recent-sales-help .help-popover-content strong { font-size: 12px !important; }
  #posSalesPanel .pos-recent-sales-help .help-popover-content p { font-size: 11px !important; line-height: 1.45; }

  /* 只缩小商品编辑器中“商品名称”四字标签，输入框内的真实商品名称保持原尺寸。 */
  #posProductEditor .pos-editor-name-field > .pos-field-label {
    font-size: 11px !important;
    line-height: 1.2;
  }

  /* 商品编辑器的条码保持紧凑，更新时间移到商品名称右侧。 */
  #posProductEditor .pos-editor-heading-barcode > small,
  #posProductEditor .pos-editor-name-heading .pos-meta-updated-at {
    font-size: 9px !important;
    line-height: 1.2;
  }
  #posProductEditor .pos-editor-heading-barcode > strong {
    font-size: 13px !important;
    line-height: 1.2;
  }
  .android-native-shell #posProductEditor .pos-recent-sales-heading-actions > #togglePosRecentSales {
    height: auto !important;
    min-height: 0 !important;
    padding: 2px 6px !important;
    font-size: 9px !important;
    line-height: 1.2 !important;
  }
  .android-native-shell #togglePosRecentSales > .zeken-expand-chevron {
    flex-basis: 16px;
    width: 16px;
    height: 16px;
  }
  .android-native-shell #togglePosRecentSales > .zeken-expand-chevron svg {
    flex-basis: 14px;
    width: 14px;
    min-width: 14px;
    max-width: 14px;
    height: 14px;
  }

  /* 仅收紧人民币报价卡，保留完整数值和币种；极窄屏说明允许换行。 */
  #renminbiRate .yuan-quote-card .rate-card-title { gap: 5px; }
  #renminbiRate .yuan-quote-card .rate-card-title > i {
    width: 26px; height: 26px; border-radius: 8px; font-size: 13px;
  }
  #renminbiRate .yuan-quote-title-row > strong {
    font-size: clamp(10px, 7.3cqi, 13px) !important;
    line-height: 1.25;
  }
  #renminbiRate .yuan-quote-title-row > .help-popover > summary {
    width: 20px; min-width: 20px; height: 20px; min-height: 20px;
    font-size: 11px !important;
  }
  #renminbiRate .yuan-quote-card output {
    min-width: 0;
    font-size: clamp(15px, 13cqi, 24px) !important;
    line-height: 1.25;
    white-space: nowrap;
  }
  #renminbiRate .yuan-quote-card output .yuan-rate-prefix,
  #renminbiRate .yuan-quote-card output .yuan-rate-unit {
    font-size: clamp(7.5px, 5.5cqi, 11px) !important;
  }
  #renminbiRate .yuan-quote-card > small {
    min-width: 0;
    font-size: clamp(8px, 5.4cqi, 11px) !important;
    line-height: 1.3;
    letter-spacing: 0;
  }

  /* 人民币报价卡的牌价时间保持一行，避免窄屏把日期和时刻拆开。 */
  #renminbiRate .yuan-quote-card time {
    min-width: 0;
    font-size: clamp(7px, 2.25vw, 8.8px) !important;
    line-height: 1.15;
    letter-spacing: -.015em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
  }

  /* Login and first-time database setup. */
  .auth-card h1 { font-size: 24px; line-height: 1.2; }
  .auth-card :is(p, label, button, input) { font-size: 14px; }
  .auth-card :is(small, .eyebrow, .security-note, .username-availability) { font-size: 12px !important; line-height: 1.45; }
  .setup-brand h1 { font-size: 22px; }
  .setup-card h2,
  .binding-status h2 { font-size: 19px; }
  .setup-shell :is(p, label, button, input, summary) { font-size: 14px; }
  .setup-shell small { font-size: 12px; line-height: 1.45; }

  .box-calculator-page { width: 100%; }
  .box-calculator-summary-row { display: block; }
  .box-calculator-mode-grid { gap: 5px; padding: 8px; }
  .box-calculator-mode-button { min-height: 40px; padding: 6px 4px; gap: 4px; font-size: 12px !important; }
  .box-calculator-mode-button .ui-nav-icon { flex-basis: 22px; width: 22px; height: 22px; border-radius: 7px; font-size: 11px; }
  .box-calculator-total-card { padding: 12px 10px 11px; }
  .box-calculator-total-heading { gap: 6px; }
  main .box-calculator-clear-button { right: 0; top: 50%; width: auto !important; min-width: 2.4em !important; height: 1em !important; min-height: 0 !important; padding: 0 1px !important; font-size: 12px !important; line-height: 1 !important; white-space: nowrap !important; word-break: keep-all !important; transform: translateY(-50%); }
  .box-calculator-total-label { font-size: 12px !important; }
  .box-calculator-total-value { font-size: clamp(22px, 8vw, 32px) !important; }
  .box-calculator-chinese-total { font-size: 11px !important; }
  .box-calculator-remark-toggle { position: static; font-size: inherit !important; }
  .box-calculator-table-card { width: 100vw; max-width: 100vw; margin-left: calc(50% - 50vw); padding: 0; }
  .box-calculator-table-scroll { width: 100%; max-width: none; overflow-x: auto; }
  .box-calculator-table { width: 100%; min-width: 100%; max-width: none; table-layout: auto; }
  .box-calculator-table.box-calculator-box-mode { width: 100%; min-width: 100%; table-layout: auto; }
  .box-calculator-table.box-calculator-add-mode { width: 100%; min-width: 0; table-layout: auto; }
  .box-calculator-table.box-calculator-add-mode td[data-box-column="product"] input,
  .box-calculator-table.box-calculator-add-mode td[data-box-column="boxes"] input { width: 100% !important; min-width: 0 !important; }
  .box-calculator-table.box-calculator-multiply-mode { width: 100%; min-width: 0; table-layout: auto; }
  .box-calculator-table.box-calculator-multiply-mode td[data-box-column="units"] input,
  .box-calculator-table.box-calculator-multiply-mode td[data-box-column="unit-price"] input { width: var(--box-input-width, 7ch) !important; min-width: var(--box-input-width, 7ch) !important; }
  .box-calculator-table th,
  .box-calculator-table td,
  .box-calculator-table input { font-size: 13px !important; }
  .box-calculator-table th { padding: 6px 8px; }
  .box-calculator-table td { padding: 3px 6px; }
  .box-calculator-table tbody tr { height: 1.3em; max-height: 1.3em; }
  .box-calculator-table tbody td:not([data-box-column="product"]) { height: 1.3em; max-height: 1.3em; min-height: 1.3em; padding-top: 0; padding-bottom: 0; overflow: hidden; line-height: 1.3; }
  .box-calculator-table tbody td[data-box-column="product"] { height: 1.3em; max-height: 1.3em; min-height: 1.3em; padding-top: 0; padding-bottom: 0; overflow: hidden; line-height: 1.3; }
  .box-calculator-table input {
    min-width: 0 !important;
    height: 1.3em !important;
    min-height: 1.3em !important;
    max-height: 1.3em !important;
    padding: 0 2px !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: 0 !important;
    line-height: 1.3 !important;
    overflow: hidden !important;
  }
  .box-calculator-table.box-calculator-box-mode input[data-box-field],
  .box-calculator-table.box-calculator-add-mode input[data-box-field],
  .box-calculator-table.box-calculator-multiply-mode input[data-box-field] {
    width: var(--box-input-width, var(--box-note-input-width, 7ch)) !important;
    min-width: 0 !important;
    white-space: nowrap !important;
  }
  .box-calculator-table input[data-box-field]:not([data-box-field="product"]) {
    width: var(--box-decimal-width, var(--box-input-width, 7ch)) !important;
    min-width: var(--box-decimal-width, var(--box-input-width, 7ch)) !important;
    padding-left: var(--box-decimal-padding-left, 2px) !important;
    padding-right: var(--box-decimal-padding-right, 2px) !important;
    text-align: left !important;
  }
  .box-calculator-note-input { width: var(--box-note-input-width, 10ch) !important; min-width: var(--box-note-input-width, 10ch) !important; max-width: none !important; max-height: calc(2.5em + 6px); padding: 3px 2px !important; }
  .box-calculator-delete-row { width: 22px; height: 22px; min-width: 22px; flex-basis: 22px; font-size: 35%; background: transparent; border-radius: 0; color: #c5263e; }
}

/* 报表子导航沿用采购子导航的卡片体系；可见项自动等宽填满一行。 */
@media (max-width: 900px) {
  #salesSubnav:not(.hidden) {
    display: flex;
    align-items: stretch;
    gap: 3px;
    overflow-x: visible;
    border-color: #ead6cc;
    background: rgba(255, 250, 244, .94);
  }
  #salesSubnav.management-subnav > .management-subtab {
    flex: 1 1 0;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 5px 2px;
    justify-content: center;
    gap: 3px;
    border-color: transparent;
    color: #6c4a49;
    background: #f8ece7;
    box-shadow: none;
    white-space: nowrap;
    text-align: center;
  }
  #salesSubnav.management-subnav > .management-subtab > .ui-nav-icon {
    width: 25px;
    height: 25px;
    flex: 0 0 25px;
    border: 1px solid rgba(109, 37, 46, .12);
    border-radius: 8px;
    color: #7b2632;
    background: rgba(255, 255, 255, .76);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .34);
    font-size: 12px;
  }

  /* 条码入口使用与条码图标一致的青绿色边框，交互状态不再回落为灰色。 */
  #priceSearch .inquiry-search-field[data-inquiry-search-mode="barcode"] {
    border-color: #62aa9f !important;
  }
  #priceSearch .inquiry-search-field[data-inquiry-search-mode="barcode"].is-active,
  #priceSearch .inquiry-search-field[data-inquiry-search-mode="barcode"]:is(:hover, :focus-within, :active) {
    border-color: #198679 !important;
    box-shadow: 0 0 0 2px rgba(25, 134, 121, .14);
  }
}

@media (max-width: 900px) {
  .box-calculator-table tbody tr,
  .box-calculator-table tbody td {
    box-sizing: border-box;
    height: 26px !important;
    min-height: 26px !important;
    max-height: 26px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    line-height: 25px !important;
    vertical-align: middle !important;
    overflow: hidden;
  }
  .box-calculator-table tbody :is(input, textarea, .box-calculator-product-cell) {
    box-sizing: border-box;
    display: block;
    height: 25px !important;
    min-height: 25px !important;
    max-height: 25px !important;
    margin: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
    border-top-width: 0 !important;
    border-bottom-width: 0 !important;
    font-size: 13px !important;
    line-height: 25px !important;
    resize: none;
    overflow: hidden;
  }
  /* 删除按钮出现时不能把已输入行撑高。 */
  .box-calculator-table tbody [data-delete-box-row] {
    box-sizing: border-box;
    height: 24px !important;
    min-height: 24px !important;
    max-height: 24px !important;
    padding: 0 !important;
    margin: 0 !important;
    line-height: 1 !important;
  }
}
