/* ================================================================
   V5 移动端设计系统 v5 — 钻艺缘
   设计稿：jewelspo.com/v5-mobile-design.html
   Discover设计语言 | 420px 全系统适配
   主色: #B8860B (香槟金) | 背景: #FAFAFA | 卡片: #FFF
   ================================================================ */

/* ── CSS 变量（全局） ── */
:root {
  --gold: #B8860B;
  --gold-light: #D4AF37;
  --bg: #FAFAFA;
  --card: #FFFFFF;
  --text: #1A1A1C;
  --text2: #666;
  --text3: #999;
  --border: #EDEDED;
  --success: #27AE60;
  --danger: #E74C3C;
  --warning: #F39C12;
  --radius: 12px;
  --shadow: 0 1px 4px rgba(0,0,0,0.04);
}

#mobileTabs { display: none; }
.mobile-only { display: none !important; }
.desktop-only-m { }

/* ═══════════════════════════════════════════
   移动端 (<480px)
   ═══════════════════════════════════════════ */
@media (max-width: 480px) {

  /* ── 1. 全局重置 ── */
  body {
    background: #FAFAFA !important;
    font-family: -apple-system, "PingFang SC", "Noto Sans SC", sans-serif;
    -webkit-tap-highlight-color: transparent;
    -webkit-font-smoothing: antialiased;
    margin: 0; padding: 0;
    color: #1A1A1C;
    font-size: 14px; line-height: 1.5;
  }
  .mobile-only { display: block !important; }
  .desktop-only-m { display: none !important; }

  /* 隐藏桌面侧边栏 */
  .sidebar-wrap, .hamburger-btn, #bottomTabs { display: none !important; }

  /* ── 顶部导航栏 ── */
  .header {
    position: fixed; top: 0; left: 0; right: 0; z-index: 1000;
    background: #fff; padding: 0 16px;
    display: flex; align-items: center; justify-content: space-between;
    height: 52px; border-bottom: 1px solid #EDEDED;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  }
  .header h1 { font-size: 17px; font-weight: 700; color: #1A1A1C; }
  .header-right { display: flex; align-items: center; gap: 12px; }
  .header-right button {
    background: none; border: none; font-size: 20px; cursor: pointer;
    padding: 6px 8px; min-width: 40px; min-height: 40px; color: #666;
    border-radius: 8px; transition: background 0.15s;
  }
  .header-right button:active { background: #f5f5f5; }
  .header-stats { display: none !important; }

  /* 容器留出 header + 底栏 */
  .container { padding: 60px 12px 80px 12px !important; }
  .container.has-sidebar { padding-left: 12px !important; }
  .page { padding: 0 !important; }
  
  .main-content { background: #FAFAFA !important; }

  /* ── 2. 金价条 ── */
  .gold-bar {
    background: #fff; border-radius: 12px; padding: 10px 0;
    margin-bottom: 12px; display: flex;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
    border: 1px solid #EDEDED;
  }
  .gold-item { 
    flex: 1; text-align: center;
    border-right: 1px solid #EDEDED;
  }
  .gold-item:last-child { border-right: none; }
  .gold-item .gold-label { font-size: 10px; color: #999; margin-bottom: 2px; }
  .gold-item .gold-price { font-size: 15px; font-weight: 700; }
  .gold-item.pt .gold-price { color: #7b7b7b; }
  .gold-item.au .gold-price { color: #B8860B; }
  .gold-item.ag .gold-price { color: #999; }

  /* ── 3. AI报价大卡 ── */
  .m-ai-card, .ai-card {
    background: linear-gradient(135deg, #FFFBF0, #fff);
    border: 1.5px solid #D4AF37; border-radius: 14px;
    padding: 20px 16px; margin-bottom: 12px;
    cursor: pointer; transition: transform 0.15s;
    text-align: center;
  }
  .m-ai-card:active, .ai-card:active { transform: scale(0.98); }
  .m-ai-card .ai-icon, .ai-card .icon { font-size: 40px; margin-bottom: 8px; }
  .m-ai-card .ai-title, .ai-card .title { font-size: 17px; font-weight: 700; color: #B8860B; }
  .m-ai-card .ai-sub, .ai-card .sub { font-size: 12px; color: #999; margin-top: 4px; }

  /* ── 4. 工具8宫格 ── */
  .m-tools-grid, .tool-grid {
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: 8px; background: #fff; border-radius: 12px; padding: 12px;
    border: 1px solid #EDEDED; margin-bottom: 12px;
  }
  .m-tool-item, .tool-item {
    display: flex; flex-direction: column; align-items: center;
    padding: 12px 4px; border-radius: 10px; cursor: pointer;
    transition: background 0.15s;
    text-decoration: none; color: inherit;
  }
  .m-tool-item:active, .tool-item:active { background: #f8f6f2; }
  .m-tool-item .tool-icon, .tool-item .icon { font-size: 24px; margin-bottom: 5px; }
  .m-tool-item .tool-label, .tool-item .label { font-size: 11px; color: #666; }

  /* ── 5. 卡片系统 ── */
  .m-card, .card {
    background: #fff; border-radius: 12px; padding: 16px;
    margin-bottom: 10px; border: 1px solid #EDEDED;
    box-shadow: 0 1px 4px rgba(0,0,0,0.02);
  }
  .m-card-title, .card-title {
    font-size: 15px; font-weight: 700; color: #1A1A1C;
    margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
  }

  /* ── 6. 产品横滑区 ── */
  .section-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 10px; padding: 0 2px;
  }
  .section-header .title { font-size: 14px; font-weight: 700; }
  .section-header .more { font-size: 12px; color: #B8860B; }
  .scroll-row, .m-scroll-row {
    display: flex; gap: 10px; overflow-x: auto;
    -webkit-overflow-scrolling: touch; padding-bottom: 4px;
    margin-bottom: 12px;
  }
  .scroll-row::-webkit-scrollbar, .m-scroll-row::-webkit-scrollbar { display: none; }
  .product-card, .m-product-card {
    min-width: 145px; max-width: 160px; background: #fff;
    border-radius: 12px; overflow: hidden;
    border: 1px solid #EDEDED; flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  }
  .product-card .img, .m-product-card .prod-img {
    height: 120px; background: #f8f6f2;
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; color: #ddd;
  }
  .product-card .info, .m-product-card .prod-info { padding: 10px; }
  .product-card .name, .m-product-card .prod-name {
    font-size: 13px; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  .product-card .meta, .m-product-card .prod-meta { font-size: 11px; color: #999; margin-top: 2px; }
  .product-card .price, .m-product-card .prod-price {
    font-size: 14px; font-weight: 700; color: #B8860B; margin-top: 4px;
  }

  /* ── 7. 订单卡片 ── */
  .order-card, .m-order-card, .m-history-item {
    background: #fff; border-radius: 12px; padding: 14px;
    margin-bottom: 8px; border: 1px solid #EDEDED;
  }
  .order-card .head, .m-order-card .order-header, .m-history-item .hi-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 8px;
  }
  .order-card .name, .m-order-card .order-name, .m-history-item .hi-product {
    font-size: 14px; font-weight: 700;
  }
  .order-card .status, .m-order-card .order-status {
    font-size: 11px; padding: 3px 10px; border-radius: 10px;
  }
  .status-pending, .order-status.pending { background: #fff3e0; color: #e67e22; }
  .status-done, .order-status.done { background: #e8f5e9; color: #27ae60; }
  .order-card .detail, .m-history-item .hi-detail {
    display: flex; gap: 16px; font-size: 12px; color: #666;
    flex-wrap: wrap; margin-bottom: 6px;
  }
  .order-card .amount, .m-history-item .hi-price {
    font-size: 16px; font-weight: 700; color: #B8860B; text-align: right;
  }

  /* ── 8. 客户选择器 ── */
  .customer-bar, .m-customer-bar {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border-radius: 12px;
    padding: 12px 14px; border: 1px solid #EDEDED;
    margin-bottom: 10px;
  }
  .customer-bar .avatar, .m-customer-avatar {
    width: 42px; height: 42px; border-radius: 50%;
    background: linear-gradient(135deg, #B8860B, #D4AF37);
    color: #fff; display: flex; align-items: center;
    justify-content: center; font-size: 18px; font-weight: 700;
    flex-shrink: 0;
  }
  .customer-bar .info, .m-customer-info { flex: 1; }
  .customer-bar .name, .m-customer-name { font-size: 15px; font-weight: 700; }
  .customer-bar .tags, .m-customer-tags { display: flex; gap: 4px; margin-top: 3px; }
  .tag, .m-tag {
    font-size: 10px; padding: 2px 8px; border-radius: 10px;
    background: #e8f5e9; color: #27ae60;
  }
  .tag.loss, .m-tag.loss { background: #fff3e0; color: #e67e22; }
  .tag.markup, .m-tag.markup { background: #e3f2fd; color: #2471a3; }

  /* ── 9. 上传区 ── */
  .upload-zone, .m-upload-zone {
    background: #fff; border: 2px dashed #D4AF37;
    border-radius: 12px; padding: 28px; text-align: center;
    cursor: pointer; margin-bottom: 12px;
    transition: background 0.2s;
  }
  .upload-zone:active, .m-upload-zone:active { background: #FFFDF5; }
  .upload-zone .icon, .m-upload-zone .cam-icon { font-size: 40px; margin-bottom: 8px; }
  .upload-zone .text, .m-upload-zone .upload-text { font-size: 15px; color: #B8860B; font-weight: 600; }
  .upload-zone .hint, .m-upload-zone .upload-hint { font-size: 12px; color: #aaa; margin-top: 4px; }

  /* ── 10. 表单系统 ── */
  .form-group { margin-bottom: 14px; }
  .form-group label {
    display: block; font-size: 13px; font-weight: 600;
    color: #666; margin-bottom: 6px;
  }
  input, textarea, select {
    font-size: 16px !important; padding: 12px 14px;
    border: 1.5px solid #e0e0e0; border-radius: 10px;
    background: #fff; color: #1A1A1C; width: 100%;
    -webkit-appearance: none; transition: border-color 0.2s;
    font-family: inherit;
  }
  input:focus, textarea:focus, select:focus {
    border-color: #D4AF37; outline: none;
    box-shadow: 0 0 0 3px rgba(184,134,11,0.06);
  }

  /* ── 11. 按钮系统 ── */
  .btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 12px 24px; border: none; border-radius: 10px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    min-height: 44px; gap: 6px; transition: all 0.15s;
  }
  .btn-primary {
    background: linear-gradient(135deg, #B8860B, #D4AF37);
    color: #fff; box-shadow: 0 2px 8px rgba(184,134,11,0.2);
  }
  .btn-primary:active { transform: scale(0.97); }
  .btn-outline {
    background: #fff; color: #B8860B;
    border: 1.5px solid #D4AF37;
  }
  .btn-outline:active { background: #FFFBF0; }
  .btn-block { width: 100%; }
  .btn-row { display: flex; gap: 10px; }
  .btn-sm { padding: 6px 14px; font-size: 12px; min-height: 36px; border-radius: 8px; }
  .btn-danger { background: #E74C3C; color: #fff; }
  .btn-success { background: #27AE60; color: #fff; }

  /* ── 12. 统计数字 ── */
  .stat-row {
    display: flex; gap: 8px; margin-bottom: 12px;
  }
  .stat-box {
    flex: 1; background: #fff; border-radius: 12px;
    padding: 14px; text-align: center; border: 1px solid #EDEDED;
  }
  .stat-box .num { font-size: 22px; font-weight: 700; color: #B8860B; }
  .stat-box .lbl { font-size: 11px; color: #999; margin-top: 4px; }
  /* ── 13. 底部Tab栏（5Tab 新版） ── */
  #mobileTabs {
    display: flex !important;
    position: fixed; bottom: 0; left: 0; right: 0;
    background: #fff; border-top: 1px solid #EDEDED;
    z-index: 9999; justify-content: space-around;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.04);
    padding: 6px 0 env(safe-area-inset-bottom, 6px);
  }
  #mobileTabs .tab-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 3px; color: #B0B0B0; font-size: 10px; font-weight: 500;
    padding: 6px 0; flex: 1; cursor: pointer; border: none;
    background: none; transition: color 0.2s;
  }
  #mobileTabs .tab-item.active { color: #B8860B; font-weight: 600; }
  #mobileTabs .tab-icon { font-size: 22px; line-height: 1; }

  /* 中间凸起报价按钮 */
  #mobileTabs .tab-item.mid {
    position: relative; margin-top: -18px;
  }
  #mobileTabs .tab-item.mid .blob {
    width: 50px; height: 50px; border-radius: 50%;
    background: linear-gradient(135deg, #B8860B, #D4AF37);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; color: #fff;
    box-shadow: 0 4px 16px rgba(184,134,11,0.25);
    margin-bottom: 2px;
  }
  #mobileTabs .tab-item.mid.active .blob {
    box-shadow: 0 4px 20px rgba(184,134,11,0.4);
  }

  /* ── 14. 弹窗系统 ── */
  .modal {
    display: none; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.45); z-index: 10000;
  }
  .modal.show {
    display: flex !important;
    align-items: center; justify-content: center;
    padding: 12px;
  }
  .modal-content {
    background: #fff !important;
    border-radius: 14px !important;
    padding: 20px !important;
    max-width: 420px !important;
    width: 100% !important;
    max-height: 88vh !important;
    overflow-y: auto !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  }
  .modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; border-bottom: 1px solid #EDEDED;
    padding-bottom: 12px;
  }
  .modal-title { font-size: 17px; font-weight: 700; color: #1A1A1C; }
  .modal-close {
    background: none; border: none; font-size: 24px;
    cursor: pointer; color: #999; min-width: 44px; min-height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px;
  }
  .modal-close:active { background: #f5f5f5; }
  .modal input, .modal select, .modal textarea { font-size: 16px !important; padding: 12px; }
  .modal .btn, .modal button { min-width: 44px; min-height: 44px; font-size: 14px; }

  /* 动态overlay弹窗 */
  #orderTableOverlay > div, #orderSheetDetailOverlay > div {
    max-width: 420px !important; width: 95% !important;
    margin: 0 auto !important; border-radius: 14px !important;
  }

  /* ── 15. 表格系统（横滑） ── */
  .mini-table, .m-param-table {
    width: 100%; border-collapse: collapse; font-size: 12px;
  }
  .mini-table td, .m-param-table td { padding: 5px 8px; border-bottom: 1px solid #f5f5f5; }
  .mini-table .lbl, .m-param-table .p-label { color: #999; }
  .mini-table .val, .m-param-table .p-value { font-weight: 600; text-align: right; }
  .mini-table .val.gold, .m-param-table .p-value.gold { color: #B8860B; }

  .data-table, table {
    display: block; overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 12px; width: 100%; border-radius: 10px;
  }
  .data-table th, .data-table td {
    padding: 8px 10px; text-align: left;
    border-bottom: 1px solid #f0f0f0; white-space: nowrap;
  }
  .data-table th {
    background: #fafafa; font-weight: 600; color: #666;
    position: sticky; top: 0; z-index: 1;
  }
  .data-table img { width: 40px; height: 40px; object-fit: cover; border-radius: 6px; }

  /* ── 16. 个人中心 ── */
  .hero-strip {
    background: linear-gradient(135deg, #1A1A1C, #2A2A2C);
    border-radius: 12px; padding: 20px; color: #fff;
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 12px;
  }
  .hero-strip .brand-icon {
    width: 48px; height: 48px; border-radius: 12px;
    background: var(--gold); display: flex; align-items: center;
    justify-content: center; font-size: 24px; flex-shrink: 0;
  }
  .hero-strip h3 {
    font-family: 'Playfair Display', serif;
    font-size: 20px; font-weight: 400;
  }
  .hero-strip .sub { font-size: 12px; opacity: 0.6; margin-top: 2px; }

  .m-profile-header {
    background: #fff; border-radius: 12px; padding: 24px 20px;
    text-align: center; margin-bottom: 12px;
    border: 1px solid #EDEDED;
  }
  .m-avatar-circle {
    width: 68px; height: 68px; border-radius: 50%;
    background: linear-gradient(135deg, #B8860B, #D4AF37);
    color: #fff; font-size: 28px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 12px; box-shadow: 0 4px 12px rgba(184,134,11,0.2);
  }
  .m-profile-name { font-size: 18px; font-weight: 700; color: #1A1A1C; }
  .m-profile-title {
    display: inline-block; font-size: 11px; color: #B8860B;
    background: #FFFBF0; padding: 3px 12px; border-radius: 20px;
    margin-top: 6px;
  }
  .m-profile-phone { font-size: 13px; color: #999; margin-top: 6px; }

  /* ── 我的订单双卡 ── */
  .m-order-cards { display: flex; gap: 10px; margin-bottom: 12px; }
  .m-order-cards .m-order-mini {
    flex: 1; background: #fff; border-radius: 12px;
    padding: 16px; text-align: center; border: 1px solid #EDEDED;
    cursor: pointer; transition: background 0.15s;
  }
  .m-order-cards .m-order-mini:active { background: #fafcf8; }
  .m-order-cards .om-icon { font-size: 28px; margin-bottom: 6px; }
  .m-order-cards .om-label { font-size: 12px; color: #999; }
  .m-order-cards .om-count { font-size: 22px; font-weight: 700; color: #1A1A1C; margin-top: 4px; }

  /* ── 财务卡片 ── */
  .m-finance-card {
    background: #fff; border-radius: 12px; padding: 14px;
    border: 1px solid #EDEDED; cursor: pointer; margin-bottom: 10px;
  }
  .m-finance-card:active { background: #fafcf8; }
  .m-finance-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 6px 0; font-size: 13px;
  }
  .m-finance-row .fin-label { color: #666; }
  .m-finance-row .fin-value { font-weight: 600; }
  .m-finance-row .fin-value.red { color: #E74C3C; }

  /* ── 结算选择卡 ── */
  .m-billing-select-card {
    background: #fff; border-radius: 12px; padding: 14px;
    border: 1px solid #EDEDED; margin-bottom: 10px;
  }

  /* ── 客户选择器 select ── */
  .m-customer-select {
    flex: 1; font-size: 16px !important; padding: 12px;
    border: 1.5px solid #e0e0e0; border-radius: 10px;
    background: #fff; min-width: 0; color: #1A1A1C;
    -webkit-appearance: none;
  }

  /* ── 个人徽章 ── */
  .m-profile-badge {
    background: #FFFBF0; color: #B8860B;
    padding: 3px 12px; border-radius: 20px; font-size: 11px;
    display: inline-block;
  }

  /* ── 17. Toast ── */
  .toast {
    position: fixed; bottom: 80px; left: 16px; right: 16px;
    background: #333; color: #fff; padding: 14px 20px;
    border-radius: 12px; text-align: center; font-size: 14px;
    opacity: 0; transition: opacity 0.3s; z-index: 20000;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  }
  .toast.show { opacity: 1; }
  .toast.success { background: #27AE60; }
  .toast.error { background: #E74C3C; }

  /* ── 18. 产品搜索页 ── */
  .m-search-bar {
    display: flex; align-items: center; gap: 8px;
    background: #fff; padding: 10px 14px;
    border: 1px solid #EDEDED; border-radius: 12px;
    margin-bottom: 10px;
  }
  .m-search-bar input {
    flex: 1; border: none; background: transparent;
    font-size: 14px !important; padding: 8px; outline: none;
  }
  .m-cat-nav {
    display: flex; gap: 0; overflow-x: auto;
    padding: 8px 0; margin-bottom: 8px;
    -webkit-overflow-scrolling: touch;
  }
  .m-cat-nav::-webkit-scrollbar { display: none; }
  .m-cat-item {
    flex-shrink: 0; text-align: center; padding: 6px 10px;
    cursor: pointer; font-size: 11px; color: #999;
  }
  .m-cat-item .cat-icon {
    width: 44px; height: 44px; border-radius: 50%;
    border: 1px solid #EDEDED; background: #fff;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 4px; font-size: 20px;
  }
  .m-cat-item.active .cat-icon {
    background: #1A1A1C; border-color: #1A1A1C;
  }
  .m-cat-item.active { color: #1A1A1C; font-weight: 600; }

  /* ── 19. 订单Tab切换 ── */
  .order-tabs {
    display: flex; background: #fff; border-radius: 12px;
    overflow: hidden; border: 1px solid #EDEDED; margin-bottom: 10px;
  }
  .order-tab {
    flex: 1; text-align: center; padding: 12px;
    font-size: 13px; color: #999; cursor: pointer;
    border-bottom: 2px solid transparent;
  }
  .order-tab.active {
    color: #B8860B; font-weight: 700;
    border-bottom-color: #B8860B;
  }

  /* ── 20. 明细表按钮栏 ── */
  .m-billing-actions { display: flex; gap: 8px; margin-bottom: 12px; }
  .m-billing-actions button {
    flex: 1; min-width: 0; padding: 12px 8px; border: none;
    border-radius: 10px; font-size: 13px; font-weight: 600;
    cursor: pointer; min-height: 44px;
  }
  .m-billing-actions .btn-new { background: #B8860B; color: #fff; }
  .m-billing-actions .btn-download { background: #27AE60; color: #fff; }
  .m-billing-actions .btn-image { background: #2471a3; color: #fff; }

  /* ── 21. 通用工具类 ── */
  .m-divider { height: 1px; background: #EDEDED; margin: 12px 0; }
  .m-section-title {
    font-size: 15px; font-weight: 700; color: #1A1A1C;
    margin-bottom: 10px; display: flex; align-items: center; gap: 6px;
  }
  .m-text-gold { color: #B8860B; }
  .m-text-center { text-align: center; }
  .m-mb { margin-bottom: 12px; }

  /* ── 22. 全局触控优化 ── */
  button, .btn, [role="button"], a[onclick],
  .m-ai-card, .ai-card, .product-card, .m-product-card,
  .m-order-mini, .m-tool-item, .tool-item,
  .m-history-item, .order-card, .upload-zone, .m-upload-zone {
    min-height: 44px; -webkit-tap-highlight-color: transparent; user-select: none;
  }
}

/* ── 平板 (481-768px) ── */
@media (min-width: 481px) and (max-width: 768px) {
  #mobileTabs { display: none !important; }
  .hamburger-btn { display: block; }
  .sidebar-wrap { transform: translateX(-100%); }
  body.sidebar-open .sidebar-wrap { transform: translateX(0); }
  .container { padding: 15px; }
}

/* ── 桌面 (>768px) ── */
@media (min-width: 769px) {
  .container.has-sidebar .page { margin-left: 220px !important; }
  #mobileTabs { display: none !important; }
}
