/* ============================================================
   全站居中与多设备可用性（覆盖层）
   1) 所有页面内容块统一居中，左右留白随视口自适应；
   2) 小屏 / 平板 / 超宽屏下布局不溢出、可滚动、可点击；
   3) 仅在必要时覆盖，不改变既有视觉风格。
   ============================================================ */

/* ---------- 1. 统一居中容器 ---------- */
:root {
  --container: min(1240px, calc(100% - 2 * var(--gutter)));
  --gutter: 24px;
}

@media (max-width: 1100px) { :root { --gutter: 20px; } }
@media (max-width: 768px)  { :root { --gutter: 16px; } }
@media (max-width: 420px)  { :root { --gutter: 12px; } }

main,
#main-content {
  margin-inline: auto;
  width: 100%;
}

/* 所有页面级区块居中 */
.order-page,
.section,
.studio-section,
.support-page,
.form-page,
.ops-board {

  margin-inline: auto;
}

/* 后台管理页不受影响，但前台所有卡片/面板都保证可收缩 */
.about-grid,
.detail-layout,
.order-detail-grid,
.sales-profile-grid,
.ops-main-grid,
.ops-kpi-grid,
.support-layout,
.checkout-layout,
.trust-pillars-inner,
.category-bento,
.product-grid,
.steps-row {
  width: 100%;
}

/* ---------- 2. 防溢出（任何设备都能看全） ---------- */
html, body { max-width: 100%; overflow-x: hidden; }

img, video, svg, canvas { max-width: 100%; }

/* 长串文本（邮箱、单号、链接）不撑破布局 */
.order-info dd,
.timeline-detail,
.purchase-meta,
.sales-masthead-mail a,
.ops-recent-title,
.ops-recent-meta,
.ops-status-name,
.ops-cat-name,
td, th, dd, dt {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* 表格类区块可横向滚动而不溢出页面 */
.order-list,
.ops-list-section,
.panel,
.about-stat-card {
  min-width: 0;
}

/* 页面内横向可滚动容器（避免撑破） */
.table-scroll,
.ops-table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---------- 3. 触控友好 ---------- */
button,
.btn,
.nav-dropdown-item-btn,
.nav-dropdown-panel a,
.auth-tab,
.order-filter-status,
.search-submit,
input[type="checkbox"],
input[type="radio"] {
  touch-action: manipulation;
}

@media (pointer: coarse) {
  .nav-dropdown-item-btn,
  .nav-dropdown-panel a { min-height: 44px; display: flex; align-items: center; }
  .btn { min-height: 44px; }
  .icon-btn, .icon-button, .btn-icon { min-width: 44px; min-height: 44px; }
  input, select, textarea { font-size: 16px; } /* 防止 iOS 聚焦自动放大 */
}

/* ---------- 4. 表单 / 输入在窄屏可用 ---------- */
input, select, textarea, button { max-width: 100%; }

.field-with-action { flex-wrap: nowrap; }
@media (max-width: 480px) {
  .field-with-action { flex-wrap: wrap; }
  .field-with-action .btn-code { width: 100%; }
}

/* ---------- 5. 布局断点补齐 ---------- */
@media (max-width: 1024px) {
  .sales-profile-grid,
  .order-detail-grid,
  .checkout-layout,
  .detail-layout,
  .support-layout,
  .ops-main-grid { grid-template-columns: 1fr; }

  .sales-card-invite { position: static; }
}

@media (max-width: 900px) {
  .nav-user-label { max-width: 120px; }
  .footer-inner,
  .footer-grid { grid-template-columns: 1fr; gap: 20px; }
}

/* 订单行在平板上改为两列，在手机上改为单列卡片 */
@media (max-width: 900px) and (min-width: 641px) {
  .order-row, .order-row-staff { grid-template-columns: 1fr 1fr; row-gap: 8px; }
  .order-row .order-title, .order-row-staff .order-title { grid-column: 1 / -1; }
}

@media (max-width: 640px) {
  .order-row, .order-row-staff {
    grid-template-columns: 1fr;
    row-gap: 6px;
    padding: 14px;
  }
  .order-row .order-title, .order-row-staff .order-title {
    grid-column: auto;
    font-size: 14px;
  }
  .order-date { text-align: left; }

  .ops-kpi-grid { grid-template-columns: 1fr; }
  .ops-trend { height: 170px; }
  .ops-status-item { grid-template-columns: 66px 1fr 58px; gap: 8px; }
  .ops-cat-list li { grid-template-columns: 82px 1fr 28px; gap: 8px; }
  .ops-recent-list a { flex-direction: column; align-items: flex-start; gap: 4px; }
  .ops-recent-title { white-space: normal; }
  .ops-recent-meta { display: flex; }

  .sales-masthead { padding: 22px 18px 0; }
  .sales-masthead-inner { gap: 14px; }
  .sales-identity { gap: 14px; }
  .sales-masthead-stats { margin: 20px -18px 0; }
  .sales-stat,
  .sales-stat:first-child,
  .sales-stat:nth-child(3) { padding-left: 18px; padding-right: 8px; }
  .sales-stat-value { font-size: 1.35rem; }
  .sales-card { padding: 20px 16px; }
  .sp-field-row { grid-template-columns: 1fr; }
  .sales-avatar { width: 60px; height: 60px; border-radius: 16px; font-size: 1.6rem; }
  .sales-trust-strip { grid-template-columns: 1fr; }

  .auth-card { padding: 24px 18px; }
  .auth-page { padding: 28px 14px; }

  .order-page,
  .support-page,
  .form-page,
  .studio-section { padding-left: 0; padding-right: 0; }

  h1 { font-size: clamp(22px, 6vw, 30px); }
  .section-header h1, .section-header h2, .form-heading h1 { font-size: clamp(1.5rem, 5vw, 1.9rem); }

  /* 悬浮客服按钮缩成圆形，避免遮挡内容 */
  .support-fab { right: 14px; bottom: 16px; }
  .chat-widget { right: 8px; left: 8px; width: auto; bottom: 80px; }
}

@media (max-width: 380px) {
  :root { --gutter: 10px; }
  .ops-status-item { grid-template-columns: 58px 1fr 52px; }
  .ops-cat-list li { grid-template-columns: 70px 1fr 24px; }
  .sales-stat-value { font-size: 1.2rem; }
}

/* ---------- 6. 超宽屏：保持在中央，不拉伸 ---------- */
@media (min-width: 1600px) {
  .order-page,
  .ops-board,
  .support-page { max-width: 1320px; }
  .section, .studio-section { max-width: 1240px; }
}

/* ---------- 7. 横向放置 / 矮屏手机 ---------- */
@media (max-height: 500px) and (orientation: landscape) {
  .chat-widget {
    max-height: calc(100vh - 24px);
    top: 12px; bottom: 12px;
  }
  .auth-page { min-height: auto; padding: 20px 14px; }
}

/* ---------- 8. 打印 ---------- */
@media print {
  .topbar, .site-footer, .support-fab, .chat-widget, .nav-dropdown { display: none !important; }
  main { width: 100%; max-width: none; }
}
