/* ============================================================
   微信 H5 / 移动端适配
   - viewport-fit=cover 配合安全区变量，适配刘海屏和底部 Home 条
   - 16px 输入框避免 iOS 聚焦自动放大
   - table-wrap / modal 支持触摸惯性滚动
   ============================================================ */

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html,
body {
  /* 保留纵向触摸滚动，只禁用双击缩放 */
  touch-action: manipulation;
}

/* 首页使用 Bootstrap 栅格时抵消负边距，避免 1~2px 横向溢出 */
.system-home .row {
  margin-left: 0;
  margin-right: 0;
}

body {
  min-height: 100vh;
  min-height: var(--app-height, 100dvh);
}

/* 微信内 iOS：输入框聚焦时留出滚动空间，避免被软键盘盖住 */
input,
select,
textarea {
  font-size: 16px;
  scroll-margin-top: 110px;
  scroll-margin-bottom: 160px;
}

/* 关闭移动端点击高亮，统一由按钮/卡片自身样式反馈 */
a,
button,
input,
select,
textarea,
label {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

@supports (padding: max(0px)) {
  body {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }

  .topbar {
    padding-left: max(20px, env(safe-area-inset-left));
    padding-right: max(20px, env(safe-area-inset-right));
    padding-top: max(8px, env(safe-area-inset-top));
  }
}

/* 桌面端不显示手机表格滑动提示 */
.mobile-table-hint {
  display: none;
}

/* 散卖登记：手机端把保存按钮移到顶部“查看散卖记录”旁边 */
.retail-save-top {
  display: none;
}

.page-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 手机端订单表头“下单日期”，桌面端保留“下单时间” */
.label-mobile {
  display: none;
}

@media (max-width: 767.98px) {
  /* 手机端按钮加大，方便店员戴手套/单手点击 */
  .btn {
    min-height: 44px;
    padding: 10px 14px;
    font-size: 14px;
  }

  .btn-small {
    min-height: 38px;
    padding: 8px 11px;
    font-size: 13px;
  }

  .qty-input,
  .money-input {
    min-height: 40px;
  }

  /* 后台表格横向触摸滚动 */
  .table-wrap,
  .table-responsive {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
  }

  /* 弹窗高度使用 JS 维护的真实视口，避免键盘弹出后弹窗被顶出屏幕 */
  .modal {
    padding: 8px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    align-items: flex-start;
  }

  .modal-box {
    max-height: calc(var(--app-height, 100dvh) - 16px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: calc(18px + env(safe-area-inset-bottom));
  }

  .page-actions {
    width: 100%;
  }

  .page-actions .btn {
    flex: 1 1 auto;
  }

  .system-card {
    min-height: 0;
  }

  /* 手机端库存总览：重点列在前，价格隐藏，其余列横向滑动查看 */
  .mobile-table-hint {
    display: block;
    margin: 0 0 8px;
    color: var(--muted);
    font-size: 12px;
  }

  .inventory-table {
    min-width: 560px;
  }

  .inventory-table th,
  .inventory-table td {
    padding: 8px 6px;
    font-size: 13px;
    white-space: nowrap;
  }

  .inventory-table th {
    font-size: 12px;
  }

  .inventory-table .item-name {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 90px;
    background: #fff;
    white-space: nowrap;
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.06);
  }

  .inventory-table th.item-name {
    z-index: 3;
    background: #f8fafc;
  }

  .inventory-table tbody tr:hover td.item-name {
    background: #fbfcfd;
  }

  .inventory-table .col-price {
    display: none;
  }

  /* 手机端订单列表：订单号固定，其余列按业务顺序横向排列 */
  .label-desktop {
    display: none;
  }

  .label-mobile {
    display: inline;
  }

  .orders-table {
    display: block;
    min-width: 1246px;
  }

  .orders-table thead,
  .orders-table tbody {
    display: block;
  }

  .orders-table tr {
    display: flex;
    width: 100%;
  }

  .orders-table th,
  .orders-table td {
    flex: 0 0 auto;
    padding: 8px 6px;
    font-size: 13px;
  }

  .orders-table th {
    font-size: 12px;
  }

  .orders-table .col-order {
    order: 0;
    width: 66px;
    position: sticky;
    left: 0;
    z-index: 2;
    background: #fff;
    box-shadow: 2px 0 4px rgba(15, 23, 42, 0.06);
  }

  .orders-table th.col-order {
    z-index: 3;
    background: #f8fafc;
  }

  .orders-table tbody tr:hover td.col-order {
    background: #fbfcfd;
  }

  .orders-table .col-pay {
    order: 1;
    width: 84px;
  }

  .orders-table .col-name {
    order: 2;
    width: 86px;
  }

  .orders-table .col-phone {
    order: 3;
    width: 112px;
  }

  .orders-table .col-content {
    order: 4;
    width: 240px;
  }

  .orders-table .col-actions {
    order: 5;
    width: 180px;
  }

  .orders-table .col-note {
    order: 6;
    width: 150px;
    max-width: 150px;
    white-space: pre-wrap;
    word-break: break-word;
  }

  .orders-table .col-created {
    order: 7;
    width: 144px;
  }

  .orders-table .col-status {
    order: 8;
    width: 84px;
  }

  .orders-table .col-pickup {
    order: 9;
    width: 100px;
  }

  .retail-save-top {
    display: inline-flex;
  }

  .retail-save-bottom {
    display: none;
  }
}
