/* 经销ERP系统 样式（浅色主题） */
:root {
  --primary: #1565C0;
  --primary-dark: #0d47a1;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #212121;
  --muted: #616161;
  --border: #e0e0e0;
  --danger: #c62828;
  --success: #2e7d32;
  --warning: #e65100;
  --sidebar-w: 220px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
.hidden { display: none !important; }

/* 登录 */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #0d47a1 0%, #1565C0 55%, #1e88e5 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 12px; padding: 36px 32px; width: 380px; box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.login-brand { text-align: center; margin-bottom: 24px; }
.login-logo { display: inline-block; background: var(--primary); color: #fff; font-weight: 700; font-size: 20px; border-radius: 10px; padding: 10px 16px; margin-bottom: 12px; letter-spacing: 2px; }
.login-logo-img { display: block; width: 165px; max-width: 60%; height: auto; margin: 0 auto 12px; }
.login-slogan { color: #37474f; font-size: 17.5px; font-weight: 700; letter-spacing: .6px; margin-top: 4px; }
.login-brand h1 { font-size: 20px; color: var(--text); }
.login-brand p { color: var(--muted); font-size: 12px; margin-top: 4px; }
.login-form label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 6px; }
.login-form input { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; }
.login-form input:focus { border-color: var(--primary); }
.code-row { display: flex; gap: 8px; margin-top: 12px; }
.code-row input { flex: 1; }
.login-error { color: var(--danger); font-size: 12px; min-height: 18px; margin-top: 8px; }
.login-tip { color: var(--muted); font-size: 12px; margin-top: 12px; text-align: center; }

/* 按钮 */
.btn { border: none; border-radius: 8px; padding: 8px 16px; font-size: 14px; cursor: pointer; background: #eceff1; color: var(--text); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: #fff; border: 1px solid var(--primary); color: var(--primary); }
.btn-ghost { background: transparent; border: 1px solid var(--border); color: var(--muted); }
.btn-danger { background: #fbe9e7; color: var(--danger); }
.btn-success { background: #e8f5e9; color: var(--success); }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 6px; }

/* 布局 */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar { width: var(--sidebar-w); background: #10243e; color: #cfd8dc; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; }
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; font-weight: 600; color: #fff; font-size: 15px; border-bottom: 1px solid rgba(255,255,255,.08); }
.side-logo { display: inline-flex; align-items: center; background: #fff; border-radius: 8px; padding: 4px 6px; }
.side-logo img { display: block; height: 18px; width: auto; max-width: none; }
.side-nav { flex: 1; overflow-y: auto; padding: 10px 8px; }
.nav-group { font-size: 11px; color: #78909c; padding: 10px 10px 4px; letter-spacing: 1px; }
.nav-item { display: block; width: 100%; text-align: left; background: none; border: none; color: #cfd8dc; padding: 7px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; margin-bottom: 1px; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; }
.side-foot { padding: 14px; border-top: 1px solid rgba(255,255,255,.08); }
.side-foot .btn + .btn { margin-top: 8px; }
.side-user { font-size: 12px; color: #90a4ae; margin-bottom: 6px; word-break: break-all; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.side-user-mail { color: #cfd8dc; max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }
.topbar { background: var(--card); padding: 14px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 5; }
.topbar h2 { font-size: 17px; }
.topbar-actions { display: flex; gap: 8px; }
.view-body { padding: 20px 24px; }

/* 卡片与统计 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat-card { background: var(--card); border-radius: 10px; padding: 16px 18px; border-top: 3px solid var(--primary); box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.stat-card .st-label { color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.stat-card .st-value { font-size: 22px; font-weight: 700; }
.stat-card.green { border-top-color: var(--success); }
.stat-card.green .st-value { color: var(--success); }
.stat-card.red { border-top-color: var(--danger); }
.stat-card.red .st-value { color: var(--danger); }
.stat-card.orange { border-top-color: var(--warning); }
.stat-card.orange .st-value { color: var(--warning); }

/* 表格 */
.card { background: var(--card); border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 16px; }
.card h3 { font-size: 14px; margin-bottom: 12px; color: var(--text); }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; white-space: nowrap; }
.tbl th { background: var(--bg); color: var(--muted); font-weight: 600; position: sticky; top: 0; }
.tbl tbody tr:hover { background: #f0f6ff; }
.tbl .num { text-align: right; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11.5px; }
.tag-gray { background: #eceff1; color: #546e7a; }
.tag-blue { background: #e3f2fd; color: var(--primary); }
.tag-green { background: #e8f5e9; color: var(--success); }
.tag-orange { background: #fff3e0; color: var(--warning); }
.tag-red { background: #ffebee; color: var(--danger); }

/* 搜索栏 */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar input, .toolbar select { padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; min-width: 160px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 12px; }
.form-item label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.form-item input, .form-item select, .form-item textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; background: #fff; }
.form-item input:focus, .form-item select:focus { border-color: var(--primary); }
.form-item .req::before { content: '* '; color: var(--danger); }
.form-item textarea { resize: vertical; font-family: inherit; line-height: 1.5; }

/* 证书附件上传 */
.att-upload { margin-top: 8px; }
.att-upload input[type="file"] { font-size: 12px; color: var(--muted); border: 1px dashed var(--border); border-radius: 8px; padding: 10px; background: #fafbfc; width: 100%; }
#att-list .tbl td { white-space: nowrap; }
.tbl a { color: var(--primary); text-decoration: none; }
.tbl a:hover { text-decoration: underline; }
/* 档案列表列较多，固定最小列宽避免挤压 */
#master-table table.tbl th, #master-table table.tbl td { max-width: 220px; overflow: hidden; text-overflow: ellipsis; }

/* 单据明细编辑 */
.items-editor table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.items-editor th, .items-editor td { border: 1px solid var(--border); padding: 5px 6px; }
.items-editor th { background: var(--bg); font-weight: 600; }
.items-editor select, .items-editor input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 5px 6px; font-size: 12.5px; }
.items-editor .num { text-align: right; }
.items-editor tfoot td { background: var(--bg); font-weight: 600; text-align: right; }
.btn-add-row { margin-top: 8px; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 12px; width: 860px; max-width: 96vw; max-height: 92vh; display: flex; flex-direction: column; box-shadow: 0 16px 48px rgba(0,0,0,.3); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 20px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 16px 20px; overflow-y: auto; flex: 1 1 auto; min-height: 0; -webkit-overflow-scrolling: touch; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* Toast */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #263238; color: #fff; padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 99; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.toast.err { background: var(--danger); }
.toast.ok { background: var(--success); }

.section-note { color: var(--muted); font-size: 12px; margin: 4px 0 12px; }
.empty-tip { text-align: center; color: var(--muted); padding: 30px 0; }
.detail-kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px 20px; margin-bottom: 14px; font-size: 13px; }
.detail-kv .k { color: var(--muted); }

/* 数量输入 + 单位角标 */
.qty-wrap { display: inline-flex; align-items: center; gap: 4px; width: 100%; }
.qty-wrap input { width: 100%; }
.qty-wrap i { font-style: normal; font-size: 11px; color: var(--muted); min-width: 18px; }

/* 对账单 */
.stmt-head { border-bottom: 2px solid var(--border); padding-bottom: 10px; margin-bottom: 12px; }
.stmt-head h2 { font-size: 18px; text-align: center; margin-bottom: 10px; }
.stmt-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 24px; font-size: 13px; }
.stmt-meta .k { color: var(--muted); }
.muted { color: var(--muted); }

@media print {
  .side, .topbar, .toolbar, .view-actions { display: none !important; }
  .card { box-shadow: none; border: none; }
}

/* 价格政策命中提示 */
.price-hint { display: block; font-size: 10px; line-height: 1.3; margin-top: 2px; color: var(--muted); font-style: normal; word-break: break-all; }

/* 列表内联编辑文本框（其他联系人） */
.cell-input { width: 100%; min-width: 170px; padding: 4px 8px; font-size: 12px; font-family: inherit; color: inherit; background: transparent; border: 1px dashed transparent; border-radius: 6px; }
.cell-input::placeholder { color: #b0b0b0; }
.cell-input:hover { border-color: var(--border); background: #fafbfc; }
.cell-input:focus { outline: none; border: 1px solid var(--primary); background: #fff; box-shadow: 0 0 0 2px rgba(21,101,192,.08); }

/* 驾驶舱分组标题与蓝色数值卡 */
.stat-card.blue .st-value { color: var(--primary); }
.stat-title { font-size: 13px; font-weight: 600; color: var(--muted); margin: 4px 0 10px; }

/* 报表统计：期间切换、双列布局、条形单元格 */
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; }
.seg button { border: none; background: transparent; padding: 7px 16px; font-size: 13px; cursor: pointer; color: var(--muted); }
.seg button:hover { background: #f5f7fa; }
.seg button.active { background: var(--primary); color: #fff; }
.rep-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 14px; margin-bottom: 18px; }
.rep-cols .card { margin-bottom: 0; }
.bar-wrap { position: relative; display: flex; justify-content: flex-end; align-items: center; min-width: 160px; padding: 5px 8px; }
.bar-wrap .bar { position: absolute; left: 0; top: 3px; bottom: 3px; border-radius: 4px; background: rgba(21,101,192,.16); }
.bar-wrap .bar.green { background: rgba(46,125,50,.16); }
.bar-wrap span { position: relative; z-index: 1; font-variant-numeric: tabular-nums; }

/* 金蝶式列表：过滤条 / 合计 / 分页 */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 12px; margin-bottom: 12px; background: #f7f9fb; border: 1px solid var(--border); border-radius: 8px; }
.filter-bar .f-input { height: 30px; padding: 0 8px; font-size: 13px; font-family: inherit; color: inherit; background: #fff; border: 1px solid var(--border); border-radius: 6px; }
.filter-bar input.f-input[data-f="kw"] { min-width: 210px; }
.filter-bar .f-sep { color: var(--muted); font-size: 12px; }
.filter-bar .f-check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--muted); cursor: pointer; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px 2px; font-size: 13px; color: var(--muted); }
.pager .sum-info b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.pager .pg-btns { display: inline-flex; align-items: center; gap: 6px; }
.pager .pg-btns button { min-width: 30px; height: 28px; padding: 0 8px; font-size: 12px; color: var(--text); background: #fff; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; }
.pager .pg-btns button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pager .pg-btns button:disabled { opacity: .45; cursor: not-allowed; }
.pager .pg-btns button.on { background: var(--primary); border-color: var(--primary); color: #fff; }
/* 单据流 */
.flow-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.flow-item { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; font-size: 12px; background: #f7f9fb; border: 1px solid var(--border); border-radius: 16px; }
.flow-item a { color: var(--primary); text-decoration: none; }
.flow-item .fl-date { color: var(--muted); }
.detail-h { font-size: 13px; font-weight: 600; margin: 14px 0 6px; color: var(--muted); }

/* 表格合计行（收发存 / 列表合计） */
.tbl tfoot td { background: #f2f6fa; font-weight: 600; }
.tbl thead tr:first-child th[colspan] { text-align: center; border-bottom: 1px solid var(--border); }

/* ============================================================
   移动端适配（手机 / 平板竖屏）
   断点：900px 为导航收起，640px 为弹窗全屏与紧凑布局
   ============================================================ */
.m-menu-btn { display: none; }
.side-mask { display: none; }

/* 弹窗打开时锁定背景滚动 */
body.modal-open { overflow: hidden; }

@media (max-width: 900px) {
  /* 侧边栏改为抽屉 */
  .app { display: block; }
  .sidebar {
    width: 84vw; max-width: 300px;
    transform: translateX(-100%); visibility: hidden;
    transition: transform .22s ease, visibility .22s ease;
    z-index: 60; box-shadow: 6px 0 24px rgba(0,0,0,.3);
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  body.nav-open .sidebar { transform: translateX(0); visibility: visible; }
  .side-mask {
    display: block; position: fixed; inset: 0; z-index: 55;
    background: rgba(0,0,0,.45); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  body.nav-open .side-mask { opacity: 1; pointer-events: auto; }
  body.nav-open { overflow: hidden; }
  .nav-item { padding: 12px 12px; font-size: 15px; }   /* 手指点按更易命中 */
  .nav-group { padding: 14px 10px 6px; }

  .main { margin-left: 0; }
  .topbar {
    padding: 10px 12px; gap: 8px; z-index: 20;
    padding-top: calc(10px + env(safe-area-inset-top));
    box-shadow: 0 1px 3px rgba(0,0,0,.05);
  }
  .topbar h2 { font-size: 16px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-actions { flex-shrink: 0; gap: 6px; max-width: 58vw; overflow-x: auto; scrollbar-width: none; }
  .topbar-actions::-webkit-scrollbar { display: none; }
  .topbar-actions .btn { white-space: nowrap; }

  .m-menu-btn {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    width: 34px; height: 34px; padding: 0 6px; flex-shrink: 0;
    background: transparent; border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  }
  .m-menu-btn span { display: block; height: 2px; width: 100%; background: var(--text); border-radius: 2px; }

  .view-body { padding: 12px 12px calc(28px + env(safe-area-inset-bottom)); }
  .card { padding: 12px; border-radius: 10px; }
  .card h3 { font-size: 14px; }

  /* 统计卡两列，避免单列过长 */
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat-card { padding: 12px 12px; }
  .stat-card .st-label { font-size: 11.5px; margin-bottom: 4px; }
  .stat-card .st-value { font-size: 17px; word-break: break-all; }

  /* 表单与详情节纵向排列 */
  .form-grid { grid-template-columns: 1fr; gap: 10px; }
  .detail-kv, .stmt-meta { grid-template-columns: 1fr; gap: 6px; }
  .rep-cols { grid-template-columns: 1fr; gap: 12px; }

  /* 触摸输入改为 16px，避免 iOS 聚焦自动放大页面 */
  input, select, textarea { font-size: 16px; }
  .form-item input, .form-item select, .form-item textarea { padding: 10px 10px; }
  .login-form input { padding: 12px; }

  /* 表格：整块可横向滑动，首列吸附便于定位 */
  .table-wrap { margin: 0; padding: 0; }
  .tbl th, .tbl td { padding: 8px; font-size: 12.5px; }
  .tbl th:first-child, .tbl td:first-child {
    position: sticky; left: 0; z-index: 2; background: var(--card);
    box-shadow: 1px 0 0 var(--border); max-width: 42vw; overflow: hidden; text-overflow: ellipsis;
  }
  .tbl th:first-child { background: var(--bg); z-index: 3; }
  .tbl tfoot td:first-child { background: #f2f6fa; }
  #master-table table.tbl th, #master-table table.tbl td { max-width: 40vw; }

  /* 单据明细编辑区横向滑动 */
  .items-editor { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -4px; padding: 0 4px; }
  .items-editor table { min-width: 660px; }
  .items-editor input, .items-editor select { padding: 7px 6px; }

  /* 过滤条与分页改为块状 */
  .filter-bar { padding: 8px; gap: 6px; }
  .filter-bar .f-input { height: 36px; flex: 1 1 100%; width: 100%; min-width: 0; }
  .filter-bar input.f-input[data-f="kw"] { min-width: 0; }
  .filter-bar .f-check { flex: 1 1 auto; }
  .pager { flex-direction: column; align-items: stretch; gap: 10px; }
  .pager .sum-info { line-height: 1.6; }
  .pager .pg-btns { justify-content: center; flex-wrap: wrap; }
  .pager .pg-btns button { min-width: 36px; height: 32px; }

  .seg { width: 100%; }
  .seg button { flex: 1; padding: 9px 8px; }
  .toolbar input, .toolbar select { min-width: 0; flex: 1 1 100%; }
  .bar-wrap { min-width: 120px; }

  /* 详情弹窗内的字段块 */
  .stmt-head h2 { font-size: 16px; }
  .flow-item { font-size: 11.5px; }

  /* 提示条移到下方，避让顶部 */
  .toast {
    top: auto; bottom: calc(24px + env(safe-area-inset-bottom));
    left: 12px; right: 12px; transform: none; text-align: center;
    padding: 12px 16px; font-size: 13.5px;
  }
}

@media (max-width: 640px) {
  /* 弹窗全屏 */
  .modal-mask { padding: 0; align-items: stretch; }
  .modal {
    width: 100%; max-width: 100%; height: 100vh; height: 100dvh;
    max-height: 100vh; max-height: 100dvh; border-radius: 0;
  }
  .modal-head {
    position: sticky; top: 0; z-index: 3; background: #fff;
    padding: 12px 14px; padding-top: calc(12px + env(safe-area-inset-top));
  }
  .modal-head h3 { font-size: 15px; padding-right: 8px; }
  .modal-close { font-size: 26px; width: 36px; height: 36px; flex-shrink: 0; }
  .modal-body { padding: 12px 14px; }
  .modal-foot {
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom));
    flex-wrap: wrap; gap: 8px;
  }
  .modal-foot .btn { flex: 1 1 45%; min-height: 44px; }

  .login-wrap { padding: 16px; align-items: center; }
  .login-card { width: 100%; padding: 26px 20px; }
  .login-brand h1 { font-size: 19px; }

  .btn { padding: 10px 16px; }          /* 触屏按钮更易点 */
  .btn-sm { padding: 6px 10px; font-size: 12.5px; }
  .card { padding: 10px; }
  .view-body { padding: 10px 10px calc(24px + env(safe-area-inset-bottom)); }
  .table-wrap { margin: 0; padding: 0; }
  .stat-card .st-value { font-size: 16px; }
  .form-item label { font-size: 12.5px; }
  .section-note { font-size: 11.5px; line-height: 1.6; }
}

/* 横屏手机：减少纵向留白 */
@media (max-width: 900px) and (orientation: landscape) {
  .modal { height: 100dvh; }
  .stat-card .st-value { font-size: 16px; }
}

/* ============================================================
   移动端补充规则（放在最后，便于覆盖）
   ============================================================ */

/* 顶栏内的期间切换按内容宽度，避免按钮被压扁 */
@media (max-width: 900px) {
  .topbar-actions .seg { width: auto; }
  .topbar-actions .seg button { flex: none; padding: 8px 11px; font-size: 12.5px; white-space: nowrap; }
  .filter-bar .btn { flex: 1 1 44%; min-height: 36px; }
  .filter-bar input.f-input[type="date"] { flex: 1 1 42%; }
  .filter-bar .f-sep { flex: 0 0 auto; }
}

/* 深色侧栏内的次级按钮（退出登录）可读性 */
.sidebar .btn-ghost { color: #cfd8dc; border-color: rgba(255,255,255,.22); }
.sidebar .btn-ghost:hover { color: #fff; border-color: rgba(255,255,255,.45); }

/* 触屏细节：去掉点击高亮与双击缩放延迟 */
.btn, .nav-item, .m-menu-btn, .seg button, .pager .pg-btns button, .modal-close, .tbl a, .cell-input {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.detail-kv > div, .stmt-meta > div, .flow-item { word-break: break-word; }

/* 手机表格：首列吸附便于对齐，操作按钮保持紧凑一行 */
@media (max-width: 900px) {
  .tbl th:first-child, .tbl td:first-child { max-width: 42vw; min-width: 96px; }
  .tbl td:last-child { white-space: nowrap; }
  .tbl td:last-child .btn { padding: 5px 8px; font-size: 12px; margin-right: 3px; }
  .modal .tbl td:last-child { white-space: normal; }
}

/* 手机上提示表格可横向滑动（滚动时仍贴在左侧） */
@media (max-width: 900px) {
  .table-wrap::after {
    content: "← 左右滑动查看全部列 →";
    display: block; position: sticky; left: 0; width: max-content;
    padding: 6px 2px 0; font-size: 11px; color: var(--muted);
  }
  .modal .table-wrap::after { display: none; }
}

/* ============================================================
   数据导出 & 权限设置
   ============================================================ */
/* 顶栏：标题靠左，操作与导出靠右 */
.topbar h2 { margin-right: auto; }
.topbar-actions { margin-left: auto; }
.topbar-export { display: flex; align-items: center; margin-left: 8px; flex-shrink: 0; }
.topbar-export:empty { display: none; }
.btn-export { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; flex-shrink: 0; }
.btn-export::before { content: "⤓"; font-size: 14px; line-height: 1; }

/* 侧栏用户名后的角色标签 */
.role-tag {
  display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 20px;
  background: rgba(255,255,255,.14); color: #cfd8dc; font-size: 11.5px;
}

/* 导出弹窗 */
.exp-box { display: flex; flex-direction: column; gap: 14px; }
.exp-row { display: flex; align-items: flex-start; gap: 14px; }
.exp-row > label { flex: 0 0 82px; padding-top: 6px; font-size: 13px; color: var(--muted); }
.exp-row select { flex: 1; min-width: 0; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; background: #fff; }
.exp-opts { display: flex; flex-wrap: wrap; gap: 10px 20px; padding-top: 5px; }
.exp-opts label { display: inline-flex; align-items: center; gap: 6px; font-size: 13.5px; cursor: pointer; }

/* 权限矩阵 */
.perm-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.perm-stats .stat-value { font-size: 22px; font-weight: 700; }
.perm-stats .stat-unit { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 2px; }
.perm-stats .stat-sub { font-size: 12px; color: var(--muted); margin-top: 4px; overflow: hidden; text-overflow: ellipsis; }
.perm-tbl th.ctr, .perm-tbl td.ctr { text-align: center; width: 78px; }
.perm-tbl input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--primary); }
.perm-tbl input[type="checkbox"]:disabled { cursor: not-allowed; opacity: .65; }
.perm-tbl tr.perm-group td {
  background: #f2f6fa; font-weight: 600; font-size: 12.5px; color: var(--primary);
  letter-spacing: .3px; padding: 7px 10px;
}
.perm-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 14px; }
.perm-add { align-items: center; }
.perm-add input, .perm-add select { min-width: 150px; }

@media (max-width: 900px) {
  .topbar-export { margin-left: 6px; }
  .topbar-export .btn { padding: 7px 10px; font-size: 12.5px; white-space: nowrap; }
  .topbar-actions { max-width: 48vw; }
  .perm-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .exp-row { flex-direction: column; gap: 6px; }
  .exp-row > label { flex: none; padding-top: 0; }
  .exp-row select { width: 100%; }
  .perm-tbl th.ctr, .perm-tbl td.ctr { width: 62px; }
  .perm-add input, .perm-add select { min-width: 0; flex: 1 1 100%; }
  .perm-foot .btn { flex: 1 1 calc(50% - 8px); }
}

/* ---------- 订单编辑器：防错提示 / 包装换算 / 历史价按钮 ---------- */
.prod-hint { font-size: 10px; line-height: 1.3; margin-top: 2px; color: var(--muted); word-break: break-all; }
.pack-conv { display: flex; align-items: center; gap: 4px; margin-top: 2px; }
.pack-conv input { width: 64px; padding: 2px 6px; font-size: 11px; }
.pack-conv span { font-size: 10px; color: var(--muted); white-space: nowrap; }
.btn-hist { margin-top: 3px; padding: 1px 8px; font-size: 11px; display: block; }
