/* 外贸 Agent 控制台 — 设计系统
   统一的颜色/间距/圆角/阴影变量，保证各模块样式一致性。 */

:root {
  --primary: #2563eb;
  --primary-weak: #eff6ff;
  --primary-hover: #1d4ed8;
  /* v1.16 a11y：语义色对各自 -weak 浅底的对比度须 ≥ 4.5:1（WCAG AA）。
     实测（sRGB 相对亮度公式）：旧 #16a34a 3.13、#d97706 3.07、#dc2626 4.41 均不达标；
     新值 #15803d 4.76、#b45309 4.84、#b91c1c 5.91 全部通过。 */
  --success: #15803d;
  --success-weak: #ecfdf5;
  --warn: #b45309;
  --warn-weak: #fffbeb;
  --danger: #b91c1c;
  --danger-weak: #fef2f2;
  --neutral: #6b7280;
  --neutral-weak: #f3f4f6;

  --bg: #f5f7fa;
  --surface: #ffffff;
  --surface-alt: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-sub: #4b5563;
  --muted: #6b7280;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-md: 0 4px 12px rgba(16, 24, 40, .10);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .16);

  --sidebar-w: 220px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
          "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;

  /* iOS 安全区：仅在 viewport-fit=cover（PWA standalone / 全屏）下为正值，
     普通浏览器与桌面端一律求值为 0，视觉不受影响。 */
  --sat: env(safe-area-inset-top, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font); font-size: 14px; line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  /* 触屏下用自定义 :active/:hover 反馈替代系统灰色高亮块 */
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--primary); text-decoration: none; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  min-height: 100dvh; /* iOS：100vh 按 large viewport 计算，竖屏下会溢出可视区 */
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% -10%, #e0ecff 0%, transparent 60%), var(--bg);
  padding: 24px;
  padding-top: 24px;                      /* 不支持 env() 时的兜底值 */
  padding-top: calc(24px + var(--sat));
  padding-bottom: 24px;
  padding-bottom: calc(24px + var(--sab));
}
.login-card {
  width: 100%; max-width: 380px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-lg); padding: 28px;
}
.login-brand { display: flex; gap: 12px; align-items: center; margin-bottom: 22px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(135deg, var(--primary), #4f8cff);
  color: #fff; font-weight: 700; font-size: 17px;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark.sm { width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
.login-card h1 { font-size: 18px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0;
  height: 100vh;
  height: 100dvh; /* ★ 关键：100vh 在 iOS 含地址栏，会把「退出」按钮挤出可视区 */
  padding-top: var(--sat);   /* standalone 下让出状态栏 */
  padding-left: var(--sal);  /* 横屏刘海 */
  overscroll-behavior: contain;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px; padding: 18px 18px;
  border-bottom: 1px solid var(--border); font-weight: 600;
}
.nav { flex: 1; overflow-y: auto; padding: 10px 10px; overscroll-behavior: contain; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 11px; margin-bottom: 2px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-sub); font-size: 13.5px;
  font-family: var(--font); text-align: left; cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--neutral-weak); color: var(--text); }
.nav-item.active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.nav-item .ico { width: 18px; text-align: center; opacity: .85; }
.nav-group {
  padding: 12px 12px 6px; font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em;
}
/* 右上角账户区：账户信息 + 修改密码 + 退出（原在侧边栏底部，已上移至顶栏右侧） */
.topbar-user {
  display: flex; align-items: center; gap: 14px;
  flex: 0 0 auto; margin-left: auto;
  padding-left: 16px; border-left: 1px solid var(--border);
}
.tu-id { display: flex; align-items: center; gap: 9px; min-width: 0; }
.tu-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary); color: #fff; font-weight: 600; font-size: 14px;
}
.tu-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.tu-name { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tu-role { font-size: 11px; color: var(--muted); white-space: nowrap; }
.tu-actions { display: flex; align-items: center; gap: 6px; }
/* 版本号：弱化，置于账户区右侧，不参与热区 */
.topbar-user .app-ver {
  position: static; color: var(--muted); opacity: .7; font-size: 10px;
  align-self: center; pointer-events: none; margin-left: 2px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 18px 24px; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
  padding-top: 18px;                      /* 兜底值 */
  padding-top: calc(18px + var(--sat)); /* 全屏下状态栏不压住顶栏 */
}
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.content { padding: 20px 24px 40px; padding-bottom: calc(40px + var(--sab)); }

/* ---------- KPI ---------- */
.kpi-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px; padding: 16px 24px 0;
}
.kpi {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow);
  min-width: 0;   /* v1.09：网格子项允许收缩，长内容不撑破卡片 */
}
/* v1.09 卡片文字层级规范（三级字号，全部带溢出防护）：
   标题 .k-label  12px / 600   —— 单行省略，中英文混排不换行
   正文 .k-value  clamp(19~24px) / 650 —— 数值主层级，长值自动换行不溢出
   辅助 .k-hint   11.5px / 400 —— 最多两行省略，长提示截断 */
.kpi .k-label {
  font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kpi .k-value {
  font-size: clamp(19px, 2.2vw, 24px); font-weight: 650; margin-top: 4px;
  letter-spacing: -.02em; line-height: 1.25;
  overflow-wrap: anywhere; word-break: break-word;
}
.kpi .k-hint {
  font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; overflow-wrap: anywhere;
}
.kpi.alert { border-color: #fecaca; background: linear-gradient(0deg, var(--danger-weak), var(--surface)); }
.kpi.alert .k-value { color: var(--danger); }
.kpi.ok .k-value { color: var(--success); }

/* ---------- 卡片 / 区块 ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 16px; border-bottom: 1px solid var(--border); background: var(--surface-alt);
}
.card-head h3 { font-size: 14px; }
.card-body { padding: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left; padding: 10px 14px; background: var(--surface-alt);
  border-bottom: 1px solid var(--border); color: var(--text-sub);
  font-weight: 600; font-size: 12px; white-space: nowrap;
}
tbody td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfe; }
td.num, th.num { text-align: right; }
td.nowrap, th.nowrap { white-space: nowrap; }
.empty { padding: 34px; text-align: center; color: var(--muted); }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px;
  border-radius: 999px; font-size: 11.5px; font-weight: 600; white-space: nowrap;
}
.badge-soft { background: var(--neutral-weak); color: var(--text-sub); font-weight: 500; }
.badge-info { background: var(--primary-weak); color: var(--primary); }
.badge-success { background: var(--success-weak); color: var(--success); }
.badge-warn { background: var(--warn-weak); color: var(--warn); }
.badge-danger { background: var(--danger-weak); color: var(--danger); }

/* ---------- 按钮 / 表单 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 7px 13px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 13px; font-family: var(--font); font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-sub); }
.btn-ghost:hover:not(:disabled) { background: var(--neutral-weak); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; }
.icon-btn {
  background: transparent; border: 0; font-size: 20px; line-height: 1;
  color: var(--muted); cursor: pointer; padding: 0 4px;
}
.icon-btn:hover { color: var(--text); }

label { display: block; font-size: 12.5px; color: var(--text-sub); margin: 10px 0 5px; font-weight: 500; }
input, select, textarea {
  width: 100%; padding: 9px 10px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  /* ★ iOS Safari 对 font-size < 16px 的聚焦控件会整页放大且常不还原，必须 ≥16px */
  font-size: 16px; line-height: 1.4; font-family: var(--font);
  background: var(--surface); color: var(--text);
  min-height: 44px; /* 16px 字号下保证触摸目标 ≥44px */
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { min-height: 76px; resize: vertical; }
.form-error { color: var(--danger); font-size: 12.5px; margin-top: 8px; min-height: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
  padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-alt); font-size: 12px; cursor: pointer; color: var(--text-sub);
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 模态 ---------- */
.modal {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
  overscroll-behavior: contain; /* 弹窗内滚动不穿透到页面 */
}
.modal-card {
  width: 100%; max-width: 460px; background: var(--surface);
  border-radius: 12px; box-shadow: var(--shadow-lg);
  max-height: 88vh;
  max-height: 88dvh; /* iOS：地址栏收起后 88vh 会偏大，dvh 跟随可视区 */
  display: flex; flex-direction: column;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 16px 18px; overflow-y: auto; overscroll-behavior: contain; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  padding: 12px 18px; border-top: 1px solid var(--border);
  padding-bottom: 12px;                   /* 兜底值 */
  padding-bottom: calc(12px + var(--sab)); /* 全屏下底部操作按钮不被 Home Indicator 压住 */
}
/* 强制改密弹窗顶部说明 */
.modal-note {
  margin: -4px 0 12px; padding: 10px 12px;
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent);
  border-radius: 8px; color: var(--text); font-size: 13px; line-height: 1.5;
}

/* ---------- 提示 / 加载 ---------- */
.toast-wrap {
  position: fixed; top: 18px; right: 18px; z-index: 200;
  display: flex; flex-direction: column; gap: 8px;
  top: calc(18px + var(--sat)); /* 状态栏之下（无安全区时等同原 18px） */
}
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: 10px 14px; font-size: 13px; min-width: 200px; max-width: 340px;
  animation: slideIn .18s ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }

.loading {
  position: fixed; inset: 0; background: rgba(245, 247, 250, .6);
  display: flex; align-items: center; justify-content: center; gap: 10px;
  z-index: 150; color: var(--text-sub); font-size: 13px;
}
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border-strong);
  border-top-color: var(--primary); border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 响应式 ----------
   注：侧边栏抽屉化的断点统一在文末「设计系统 v2 / 响应式断点体系」的
   @media (max-width: 1024px) 段，避免此处与 v2 断点重复定义造成冲突。 */

/* ---------- CRM 详情 / 筛选 / 来源分布 ---------- */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 18px; }
.info-grid > div { display: flex; flex-direction: column; gap: 3px; }
.info-grid .lbl { font-size: 12px; color: var(--muted); }
.info-grid .val { font-size: 13.5px; color: var(--text); font-weight: 500; word-break: break-word; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; }
.filter-bar input, .filter-bar select { width: auto; min-width: 150px; flex: 1 1 160px; }
.sect-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.credit-hero { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sub { font-size: 13px; margin: 16px 0 8px; color: var(--text-sub); font-weight: 600; }
.src-bar { display: flex; flex-direction: column; gap: 9px; }
.src-row { display: flex; align-items: center; gap: 10px; }
.src-name { width: 84px; flex: 0 0 auto; font-size: 12.5px; color: var(--text-sub); }
.src-track { flex: 1; height: 14px; background: var(--neutral-weak); border-radius: 999px; overflow: hidden; }
.src-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #4f8cff); border-radius: 999px; }
.src-count { width: 36px; flex: 0 0 auto; text-align: right; font-size: 12.5px; color: var(--muted); }

/* ==========================================================================
   设计系统 v2 —— 全局 UI 一致性扩展
   目标：统一间距/字号/圆角/层级/交互反馈，补齐响应式断点与通用组件。
   原则：只新增/增强，不改动既有类名的语义；主色沿用 --primary，不另起一套。
   ========================================================================== */

/* ---------- 1. 补充设计令牌 ---------- */
:root {
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px;
  --fs-xs: 11.5px; --fs-sm: 12.5px; --fs-md: 13.5px; --fs-lg: 15px; --fs-xl: 18px;
  --radius-lg: 14px;
  --ring: 0 0 0 3px rgba(37, 99, 235, .16);
  --ring-danger: 0 0 0 3px rgba(220, 38, 38, .16);
  --ease: cubic-bezier(.4, 0, .2, 1);
}

/* ---------- 2. 焦点可见性（键盘可达性） ---------- */
a:focus-visible, button:focus-visible, .nav-item:focus-visible, .chip:focus-visible,
.mail-tab:focus-visible, .mail-folder:focus-visible, .mail-acc:focus-visible,
[role="button"]:focus-visible, .q2-link:focus-visible, .ops-link:focus-visible {
  outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm);
}
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: var(--ring); }

/* ---------- 3. 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #d6dae0; border-radius: 999px;
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #bfc5ce; background-clip: content-box; }

/* ---------- 4. 通用工具类 ---------- */
.stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row-tight { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-auto { margin-left: auto; }
.mt-1 { margin-top: var(--sp-1); } .mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); } .mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); } .mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.text-right { text-align: right; } .text-center { text-align: center; }
.text-danger { color: var(--danger); } .text-success { color: var(--success); }
.text-warn { color: var(--warn); } .text-muted { color: var(--muted); }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; } .fw-700 { font-weight: 700; }
.fs-xs { font-size: var(--fs-xs); } .fs-sm { font-size: var(--fs-sm); }
.fs-md { font-size: var(--fs-md); } .fs-lg { font-size: var(--fs-lg); }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- 5. 表单控件修复与增强 ---------- */
/* 复选框/单选框不应被 input{width:100%} 拉伸（修复权限矩阵等处） */
input[type="checkbox"], input[type="radio"] {
  width: auto; min-width: 0; margin: 0; flex: 0 0 auto; accent-color: var(--primary);
  /* 勾选项不走 input 的 44px 最小高度（由父级 label 提供可点区，见 pointer:coarse 段） */
  min-height: 0;
}
input[type="date"], input[type="datetime-local"], input[type="time"] { max-width: 100%; }
input:disabled, select:disabled, textarea:disabled {
  background: var(--neutral-weak); color: var(--muted); cursor: not-allowed;
}
input[readonly], textarea[readonly] { background: var(--surface-alt); }
select { cursor: pointer; }
.check-row {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-sub); margin: 0; cursor: pointer;
}

/* 字段容器：统一 label 与控件间距，支持两列栅格与必填标记 */
.field { margin-bottom: var(--sp-3); min-width: 0; }
.field:last-child { margin-bottom: 0; }
.field > label {
  margin: 0 0 5px; display: flex; align-items: center; gap: 4px;
  font-size: 12.5px; color: var(--text-sub); font-weight: 500;
}
.field > label .req { color: var(--danger); font-weight: 700; }
.field-hint { font-size: var(--fs-xs); color: var(--muted); margin-top: 4px; line-height: 1.5; }
.field-err { font-size: var(--fs-sm); color: var(--danger); margin-top: 4px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-3) 14px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.fieldset {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: var(--sp-3); margin-bottom: var(--sp-3); background: var(--surface-alt);
}
.fieldset > .legend {
  font-size: var(--fs-sm); font-weight: 600; color: var(--text-sub); margin-bottom: var(--sp-2);
}

/* ---------- 6. 侧边栏：移动端抽屉遮罩 ---------- */
.sidebar { transition: transform .22s var(--ease); box-shadow: none; }
.sidebar.open { box-shadow: var(--shadow-lg); }
.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .42);
  z-index: 55; opacity: 0; pointer-events: none; transition: opacity .22s var(--ease);
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
.menu-toggle {
  display: none; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0; flex: 0 0 auto;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-sub); font-size: 16px; line-height: 1; cursor: pointer;
}
.menu-toggle:hover { background: var(--neutral-weak); color: var(--text); }
/* 抽屉内的关闭按钮：桌面端常驻布局不需要，仅 ≤1024 抽屉态下显示（见断点段） */
.sidebar-brand .icon-btn { display: none; font-size: 22px; }
.nav-item { position: relative; transition: background .15s, color .15s; }
/* v1.15（审计移动端）：导航激活竖条统一由设计系统 v3 层（§active 竖条，
   top:8px/bottom:8px）定义；此处 v2 旧规则（top:50% + translateY）与其
   在不同行高的 nav-item 上产生 ~10px 视觉偏移，删除以消除双层规则打架。 */
/* ---------- 7. 顶栏 ---------- */
.topbar { align-items: center; min-height: 62px; gap: var(--sp-4); }
.topbar > div:first-child { min-width: 0; }
.topbar h2 { font-size: 17px; line-height: 1.35; }
.topbar .muted { margin-top: 2px; }
.topbar-actions { gap: var(--sp-2); align-items: center; }
.topbar-actions .btn { flex: 0 0 auto; }

/* 详情页：区块快捷导航 + 草稿编辑工具条（不进入打印/导出） */
.q2-secnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.q2-secnav-item {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-sub);
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px; cursor: pointer;
  font-family: var(--font); transition: background .15s, color .15s, border-color .15s;
}
.q2-secnav-item:hover { background: var(--neutral-weak); color: var(--text); }
.q2-editbar { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; padding: 12px; background: var(--surface-alt); border: 1px dashed var(--border); border-radius: var(--radius); }
.q2-tools { margin-top: 12px; }
.q2-line-acts { margin-top: 10px; }
.q2-field-val { font-weight: 600; color: inherit; }

/* ---------- 8. 卡片增强 ---------- */
.card-head { min-height: 46px; gap: var(--sp-3); flex-wrap: wrap; }
.card-head .head-title { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-head .head-sub { font-size: var(--fs-xs); color: var(--muted); font-weight: 400; }
.card-toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  flex-wrap: wrap; padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border); background: var(--surface-alt);
}
.card-foot {
  display: flex; align-items: center; justify-content: flex-end; gap: var(--sp-2);
  flex-wrap: wrap; padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border); background: var(--surface-alt);
}
.card-flat { box-shadow: none; }
.card-pad-0 .card-body { padding: 0; }

/* ---------- 9. 表格增强 ---------- */
/* 横向可滚动提示：左右两侧渐变阴影（scroll 附着，固定于可视边缘），
   前后两层「遮盖层」用 local 附着随内容滚动 —— 滚到尽头时自动遮住阴影。
   纯 CSS 实现，无需 JS 监听滚动。 */
.table-wrap {
  overflow-x: auto; -webkit-overflow-scrolling: touch; overscroll-behavior-x: contain;
  background-image:
    linear-gradient(to right, var(--surface) 30%, rgba(255, 255, 255, 0)),
    linear-gradient(to left,  var(--surface) 30%, rgba(255, 255, 255, 0)),
    radial-gradient(farthest-side at 0 50%, rgba(17, 24, 39, .16), rgba(17, 24, 39, 0)),
    radial-gradient(farthest-side at 100% 50%, rgba(17, 24, 39, .16), rgba(17, 24, 39, 0));
  background-position: left center, right center, left center, right center;
  background-repeat: no-repeat;
  background-size: 48px 100%, 48px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}
table { min-width: 100%; }
thead th { border-bottom: 1px solid var(--border-strong); letter-spacing: .01em; }
tbody td { padding: 11px 14px; }
tbody tr { transition: background .12s var(--ease); }
tbody tr:hover { background: #f7f9fc; }
/* 修复：操作列多个按钮紧邻无间距 */
td .btn + .btn, td .btn + .icon-btn, td .icon-btn + .btn { margin-left: 6px; }
.table-actions { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
td.num, th.num { font-variant-numeric: tabular-nums; }
td.nowrap .btn { white-space: nowrap; }

/* ---------- 10. 空状态 ---------- */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty-ico { display: block; font-size: 26px; opacity: .4; margin-bottom: 8px; line-height: 1; }
.empty-title { font-size: var(--fs-md); color: var(--text-sub); font-weight: 600; }
.empty-hint { font-size: var(--fs-sm); margin-top: 4px; }

/* ---------- 11. 徽标增强 ---------- */
.badge { letter-spacing: .01em; }
.badge-outline { background: transparent; border: 1px solid var(--border-strong); color: var(--text-sub); }

/* ---------- 12. 按钮增强 ---------- */
.btn { user-select: none; transition: background .15s, border-color .15s, opacity .15s, box-shadow .15s; }
.btn:active:not(:disabled) { transform: translateY(.5px); }
.btn-lg { padding: 9px 16px; font-size: 14px; }
.btn-warn { background: var(--warn); color: #fff; }
.btn-warn:hover:not(:disabled) { filter: brightness(.94); }
.btn-link { background: transparent; border-color: transparent; color: var(--primary); padding: 4px 6px; }
.btn-link:hover:not(:disabled) { background: var(--primary-weak); }
.btn-danger-ghost { background: var(--surface); border-color: #fecaca; color: var(--danger); }
.btn-danger-ghost:hover:not(:disabled) { background: var(--danger-weak); }
.btn-group { display: inline-flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.btn .ico { font-size: 14px; line-height: 1; }
.btn.is-loading { position: relative; pointer-events: none; opacity: .9; color: transparent !important; }
.btn.is-loading::after {
  content: ""; position: absolute; left: 50%; top: 50%; margin: -7px 0 0 -7px;
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite;
}
.btn-ghost.is-loading::after, .btn-link.is-loading::after, .btn-danger-ghost.is-loading::after {
  border-color: rgba(17, 24, 39, .12); border-top-color: var(--primary);
}

/* ---------- 13. 模态框增强 ---------- */
.modal { backdrop-filter: blur(2px); animation: modalFade .15s var(--ease); }
.modal-card { animation: modalPop .16s var(--ease); border: 1px solid var(--border); }
.modal-card.sm { max-width: 380px; }
.modal-card.md { max-width: 520px; }
.modal-card.lg { max-width: 760px; }
.modal-card.xl { max-width: 1040px; }
.modal-card.full { max-width: 94vw; }
.modal-head { background: var(--surface-alt); min-height: 50px; }
.modal-head h3 { font-size: var(--fs-lg); }
.modal-body { padding: var(--sp-4); scrollbar-gutter: stable; }
.modal-foot { background: var(--surface-alt); gap: var(--sp-2); flex-wrap: wrap; }
.modal-foot .foot-aux { margin-right: auto; font-size: var(--fs-xs); color: var(--muted); }
.modal-danger .modal-head { background: var(--danger-weak); border-bottom-color: #fecaca; }
.modal-danger .modal-head h3 { color: var(--danger); }
@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalPop {
  from { opacity: 0; transform: translateY(10px) scale(.985); }
  to { opacity: 1; transform: none; }
}

/* ---------- 14. 确认对话框 ---------- */
.confirm-card { max-width: 400px; }
.confirm-head { display: flex; gap: var(--sp-3); align-items: flex-start; }
.confirm-ico {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center; font-size: 19px; line-height: 1;
}
.confirm-ico.danger { background: var(--danger-weak); color: var(--danger); }
.confirm-ico.warn { background: var(--warn-weak); color: var(--warn); }
.confirm-ico.info { background: var(--primary-weak); color: var(--primary); }
.confirm-title { font-size: var(--fs-lg); font-weight: 600; line-height: 1.4; }
.confirm-text { font-size: var(--fs-md); color: var(--text-sub); margin-top: 5px; line-height: 1.6; }
.confirm-reason {
  margin-top: var(--sp-3); padding: var(--sp-2) 10px; font-size: var(--fs-sm); line-height: 1.55;
  background: var(--danger-weak); border: 1px solid #fecaca; border-radius: var(--radius-sm); color: var(--danger);
}

/* ---------- 15. Toast 增强 ---------- */
.toast { display: flex; align-items: flex-start; gap: var(--sp-2); line-height: 1.5; }
.toast-ico { flex: 0 0 auto; font-weight: 700; font-size: 13px; line-height: 1.45; }
.toast.success .toast-ico { color: var(--success); }
.toast.error .toast-ico { color: var(--danger); }
.toast.warn .toast-ico { color: var(--warn); }
.toast:not(.success):not(.error):not(.warn) .toast-ico { color: var(--primary); }
.toast-msg { min-width: 0; word-break: break-word; }

/* ---------- 16. KPI 增强 ---------- */
.kpi { position: relative; overflow: hidden; }
.kpi .k-ico { position: absolute; right: 14px; top: 14px; font-size: 18px; opacity: .16; line-height: 1; }
.kpi .k-value { font-variant-numeric: tabular-nums; }
/* v1.09：k-label 层级规范见顶部 KPI 段（单行省略）——此处不再覆写 display */

/* ---------- 17. 响应式断点体系 ----------
   断点：1280 / 1024 / 860 / 640 / 420
   ★ 1024 = iPad / 分屏临界带：iPad Pro 12.9 竖屏(1024)、iPad mini 横屏(1024)、
     Split View 常见分屏(1013) 都落在这里。此处统一「抽屉化 + 显示汉堡」，
     消灭原先 861~1024「侧边栏常驻且无法折叠」的夹心带；>1024 桌面端不受影响。 */
@media (max-width: 1280px) {
  .content { padding: 18px 20px calc(36px + var(--sab)); }
  .topbar { padding: 16px 20px; padding-top: calc(16px + var(--sat)); }
  .kpi-row { padding: 14px 20px 0; }
}
@media (max-width: 1024px) {
  :root { --sidebar-w: 240px; }
  /* 抽屉化：侧边栏脱离文档流靠左隐藏，主区占满整宽；由 .menu-toggle / 遮罩控制 */
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60;
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: none; }
  .menu-toggle { display: inline-flex; }
  .sidebar-brand .icon-btn { display: inline-flex; }
  .sidebar-backdrop { display: block; }
  /* 操作列解除 nowrap：iPad 768~1024 区间也放行，降低表格 min-width 与横向滚动 */
  td.nowrap, th.nowrap { white-space: normal; }
}
@media (max-width: 860px) {
  .topbar { padding: 12px 16px; padding-top: calc(12px + var(--sat)); min-height: 56px; }
  .topbar h2 { font-size: 16px; }
  .content { padding: 16px; padding-bottom: calc(16px + var(--sab)); }
  .kpi-row { padding: 12px 16px 0; }
  .card-head { padding: 12px 14px; }
  .card-body { padding: 14px; }
  .modal { padding: 14px; }
}
@media (max-width: 640px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px 13px; }
  .kpi .k-value { font-size: 19px; }   /* v1.09：两列窄卡数值层级 */
  .filter-bar input, .filter-bar select { flex: 1 1 100%; width: 100%; min-width: 0; }
  .info-grid { grid-template-columns: 1fr; gap: 10px; }
  .form-grid { grid-template-columns: 1fr; }
  .modal { padding: 10px; align-items: flex-end; }
  .modal-card { max-height: 92vh; max-height: 92dvh; max-width: 100%; }
  .modal-foot .btn { flex: 1 1 auto; }
  .topbar-actions { width: 100%; }
  .topbar-actions .btn { flex: 1 1 auto; }
  .topbar { flex-wrap: wrap; row-gap: 10px; align-items: center; }
  .topbar-user { width: 100%; margin-left: 0; padding-left: 0; border-left: none; border-top: 1px solid var(--border); padding-top: 10px; justify-content: space-between; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .kpi-row { grid-template-columns: 1fr; }
  /* v1.09：单列全宽下恢复完整层级，数值更大、标签/辅助不再省略换行错位 */
  .kpi .k-value { font-size: 21px; }
  .login-card { padding: 22px; }
}

/* ---------- 18. 触屏设备：触摸目标 ≥44px（iOS HIG） ----------
   只在 pointer: coarse（手指操作）生效，桌面端紧凑布局保持原样。 */
@media (pointer: coarse) {
  .btn, .btn-sm, .btn-link, .chip, .icon-btn, .nav-item,
  .mail-tab, .emp-tab, .mail-acc, .mail-folder, .mail-picker-item {
    min-height: 44px;
  }
  .btn-sm, .btn-link { padding: 9px 12px; }
  .chip { padding: 9px 14px; }
  .icon-btn {
    min-width: 44px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .menu-toggle { width: 44px; height: 44px; }
  /* 复选框本体 ≥20px，父级容器 ≥44px 提供可点区 */
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; }
  .emp-perm, .q2-pick-chk, .mail-chk { width: 20px; height: 20px; }
  .mail-chk { margin-top: 0; }
  .emp-perm-cell, .check-row, .mail-check, .q2-pick-qty { min-height: 44px; }
  .mail-row { min-height: 48px; }
  .mail-att-x { display: inline-flex; align-items: center; min-height: 44px; padding: 0 6px; }
}

/* ---------- 19. 软键盘 / 矮视口：弹窗改为顶部对齐，避免输入框被键盘遮住 ---------- */
@media (max-height: 600px) {
  .modal { align-items: flex-start; padding-top: calc(10px + var(--sat)); }
  .modal-card { max-height: 96vh; max-height: 96dvh; }
}

/* 尊重系统「减少动效」设置 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- 双语展示：浅色副行（分类字典 / 产品库共用） ---------- */
.dct-en, .p-en {
  margin-top: 2px;
  font-size: 11.5px; line-height: 1.4;
  color: var(--muted);
  font-weight: 500;
  letter-spacing: .01em;
}
/* 同一行内的英文对照（列表单元格里并排显示时用） */
.bi-en { color: var(--muted); font-size: 12px; font-weight: 500; }
.bi-sep { margin: 0 6px; color: var(--border); }

/* ---------- 产品规格：多行文本（产品库 / 报价 / PI / 合同共用） ----------
   规格字段已是多行输入（每行一条），这里统一按换行渲染。
   只挂在规格单元格上，避免影响其他列的垂直对齐与行高。 */
/* v1.29：去掉 min-width 硬撑（会把规格列钉死、挤压品名列），
   改由 colgroup 控制宽度 + 长内容自动折行，规格多少都能自适应。 */
.spec-cell { white-space: pre-line; line-height: 1.5; word-break: break-word; overflow-wrap: anywhere; }

/* ---------- 单据导出：格式选择（报价单 / PI / 合同共用） ---------- */
.exp-fmt { display: grid; gap: 10px; margin-bottom: 10px; }
.exp-fmt-item {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; text-align: left; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color .16s ease, background .16s ease;
}
.exp-fmt-item:hover { border-color: var(--primary); background: var(--primary-weak); }
.exp-fmt-item:disabled { cursor: progress; opacity: .7; }
.exp-fmt-ico {
  flex: 0 0 46px; height: 46px; display: grid; place-items: center;
  border-radius: 10px; font-size: 12px; font-weight: 700; letter-spacing: .04em;
}
.exp-fmt-ico.is-print { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.exp-fmt-ico.is-doc { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.exp-fmt-txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.exp-fmt-txt b { font-size: 13.5px; color: var(--text); }
.exp-fmt-txt em { font-style: normal; font-size: 12px; color: var(--muted); }

/* v65：通知深链定位行高亮（点击 AI 助手待办后落到目标行） */
tr.row-focus > td { background: var(--warning-bg, #fef3c7) !important; }
tr.row-focus > td:first-child { box-shadow: inset 3px 0 0 var(--warning, #f59e0b); }

/* v67：首次登录强制设置——关闭设置窗口后的常驻提醒横幅 */
.profile-setup-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 1400;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 9px 16px;
  background: var(--warn-weak, #fffbeb); color: var(--warn, #d97706);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
  box-shadow: 0 2px 10px rgba(0, 0, 0, .07);
  font-size: 13px;
}
.profile-setup-banner .psb-text { min-width: 0; }
.profile-setup-banner .btn { flex: 0 0 auto; }

/* ==================== v0.96：费用报销增强（明细行 / 发票图片墙） ==================== */
.fin-exp-item-row {
  display: flex; gap: 6px; align-items: center; margin-bottom: 6px; flex-wrap: wrap;
}
.fin-exp-item-row .fin-exp-ipt {
  flex: 1 1 90px; min-width: 70px; padding: 6px 8px; font-size: 13px;
  border: 1px solid var(--border, #ddd); border-radius: 6px; background: var(--bg, #fff);
}
.fin-exp-item-row .fin-exp-ipt[name="fi_desc"] { flex: 2 1 160px; }
.fin-exp-kv { display: flex; flex-direction: column; gap: 2px; }
.fin-exp-kv .lbl { font-size: 12px; color: var(--muted, #888); }
.fin-exp-kv .val { font-size: 13.5px; color: var(--text, #222); }
.fin-exp-img-wall {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px; padding: 4px 0;
}
.fin-exp-img-card {
  border: 1px solid var(--border, #e2e2e2); border-radius: 8px; overflow: hidden;
  background: var(--bg, #fff); display: flex; flex-direction: column;
}
.fin-exp-img-card a { display: block; height: 90px; background: #f6f7f9; }
.fin-exp-img-card img {
  width: 100%; height: 90px; object-fit: cover; display: block;
}
.fin-exp-img-pdf {
  height: 90px; display: grid; place-items: center; font-size: 20px; color: #dc2626;
}
.fin-exp-img-cap {
  display: flex; align-items: center; justify-content: space-between; gap: 4px;
  padding: 4px 6px; border-top: 1px solid var(--border, #eee);
}
.fin-exp-img-cap .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ==========================================================================
   设计系统 v3 —— v1.13 UI 打磨（视觉节奏 / 交互反馈 / 全尺寸适配）
   原则：沿用既有 token 与主色，不改动任何既有类名的语义；
        新增规则尽量用 :where() 保持 0 特异性，避免覆盖模块专属样式；
        所有动效只作用于 transform / opacity / color / border-color（不触发布局重排）。
   ========================================================================== */

/* ---------- 20. 主题声明与语义补充令牌 ---------- */
:root {
  /* 显式声明浅色主题：避免 Windows/浏览器深色模式下原生滚动条、下拉、
     日期控件自动变黑，保证与既有浅色界面风格统一。 */
  color-scheme: light;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --header-h: 60px;
}
::selection { background: rgba(37, 99, 235, .16); color: var(--text); }

/* ---------- 21. 视觉节奏：统一的「品牌竖条」装饰语言 ----------
   只在导航激活项与卡片标题前各加一条 3px 主色标记，形成一致的视觉锚点，
   不新增卡片、不堆叠阴影，避免「万物皆卡片」的泛化观感。 */
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px;
  width: 3px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.card-head .head-title::before {
  content: ""; display: inline-block; vertical-align: middle;
  flex: 0 0 auto; width: 3px; height: 15px;
  border-radius: 3px; background: var(--primary); opacity: .85;
}
/* 纯文本型卡片头（无 .head-title 包裹）不加装饰，保持克制 */

/* ---------- 22. 流式排版（仅中大屏，避开 860/640/420 既有断点） ----------
   用 clamp() 让标题与核心数值随视口平滑过渡，超宽屏不失控、笔记本不局促。 */
@media (min-width: 861px) {
  .topbar h2 { font-size: clamp(16px, .55vw + 12px, 20px); line-height: 1.35; }
  .kpi .k-value { font-size: clamp(22px, 1.1vw + 15px, 30px); line-height: 1.2; }
  .card-head .head-title { font-size: clamp(14px, .3vw + 12px, 16px); }
}
h1, h2, h3, h4 { line-height: 1.35; }

/* ---------- 23. 内容健壮性：长文本 / 图片 / 锚点 ---------- */
/* 0 特异性：只在没有更具体规则时兜底，避免影响模块自己的 word-break 策略 */
:where(td, th, .card-body, .modal-body, .empty-title, .empty-hint, .muted) {
  overflow-wrap: anywhere;
}
img, svg, video, canvas { max-width: 100%; }
/* 锚点跳转不被 sticky 顶栏遮挡（quote.css 对特定卡片已有 16px，此处 :where 不覆盖它） */
:where([id]):target { scroll-margin-top: calc(var(--header-h) + 12px); }

/* ---------- 24. 交互反馈：禁用态与焦点可达性 ---------- */
:where(button, .btn, input, select, textarea):disabled {
  cursor: not-allowed; opacity: .55;
}
/* 焦点环加一层透明 outline 作为兜底：box-shadow 在强制颜色模式下会被忽略 */
:where(a, button, .nav-item, [role="button"], input, select, textarea):focus-visible {
  outline: 2px solid transparent; outline-offset: 2px;
}

/* ---------- 25. 无障碍：高对比度 / 强制颜色 / 减少透明 ---------- */
@media (prefers-contrast: more) {
  :root { --border: #c3c9d2; --border-strong: #98a2b3; --muted: #475569; }
  .card, .modal-card, .btn { border-color: var(--border-strong); }
}
@media (forced-colors: active) {
  :where(a, button, .nav-item, [role="button"], input, select, textarea):focus-visible {
    outline: 2px solid Highlight; outline-offset: 2px; box-shadow: none;
  }
  .card, .modal-card, .btn, .badge { border: 1px solid CanvasText; }
  .nav-item.active::before, .card-head .head-title::before { background: Highlight; }
}
@media (prefers-reduced-transparency: reduce) {
  .modal { backdrop-filter: none; background: rgba(17, 24, 39, .6); }
  .loading { background: rgba(245, 247, 250, .94); }
}

/* ---------- 26. 全尺寸适配补强 ---------- */
/* 超宽屏：限制主内容最大宽度，避免表格与正文行长过长（保持左对齐，不居中一切） */
@media (min-width: 1680px) {
  .content { max-width: 1680px; }
}
@media (max-width: 640px) {
  /* 显式兜底：基础字号本就是 16px（见基础控件段），此处防止模块专属样式
     在窄屏把控件压到 16px 以下，触发 iOS Safari 聚焦时整页放大 */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea { font-size: 16px; }
  /* 模态框在窄屏靠底部呈现，改为底部抽屉式圆角 + 安全区内边距 */
  .modal-card { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-foot { padding-bottom: calc(var(--sp-3) + var(--sab)); }
  .toast-wrap { left: 12px; right: 12px; }
  .toast { min-width: 0; max-width: none; }
}
/* 横屏手机 / 矮视口：顶栏与 KPI 收紧，把纵向空间留给内容 */
@media (max-height: 480px) and (orientation: landscape) {
  .topbar { min-height: 48px; padding-top: calc(8px + var(--sat)); padding-bottom: 8px; }
  .kpi-row { padding-top: 8px; }
  .content { padding-top: 10px; }
}

/* ============ v1.21 签名上传版块（本人 PNG 签名预览） ============ */
.sig-preview {
  min-height: 132px; display: flex; align-items: center; justify-content: center;
  padding: 14px; border: 1px dashed var(--border); border-radius: var(--radius);
  background: #fff;
}
.sig-preview-img { max-width: 320px; max-height: 108px; object-fit: contain; }
.sig-preview-empty { text-align: center; line-height: 1.8; color: var(--muted); }
.sig-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .sig-preview-img { max-width: 90%; }
}

/* ============ v1.24 数据清空（超管专属危险操作） ============ */
.da-danger-card { border-color: var(--danger) !important; }
.da-danger-card .card-head { border-bottom-color: var(--danger-weak); color: var(--danger); }
.da-warn, .da-modal-warn {
  padding: 10px 12px; border: 1px solid var(--danger); border-radius: var(--radius-sm);
  background: var(--danger-weak); color: var(--danger); line-height: 1.65;
}
.da-modal-warn + .da-modal-warn { margin-top: 8px; }
.da-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.da-h4 { margin: 0 0 6px; font-size: 13px; }
.da-list { margin: 0; padding-left: 18px; line-height: 1.75; font-size: 12.5px; color: var(--muted); }
.da-list.da-keep { color: var(--text); }
.da-label { font-size: 13px; font-weight: 600; }
.da-label code { padding: 1px 5px; background: var(--danger-weak); color: var(--danger); border-radius: 4px; }
.da-input { max-width: 320px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); font-family: ui-monospace, Consolas, monospace; letter-spacing: .04em; }
/* v1.26 清空结果回执：删除统计 + 自检结论 + 刷新后横幅 */
.da-ok-card { border-color: var(--success) !important; }
.da-ok-card .card-head { border-bottom-color: var(--success-weak, #dcfce7); color: var(--success); }
.da-stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.da-stat { padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2, var(--surface)); }
.da-stat-n { font-size: 22px; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.da-stat-l { margin-top: 2px; font-size: 12px; color: var(--muted); }
.da-check-ok, .da-check-bad, .da-live, .da-banner-ok {
  padding: 9px 12px; border-radius: var(--radius-sm); line-height: 1.6; font-size: 12.5px;
}
.da-check-ok { border: 1px solid var(--success); background: var(--success-weak, #dcfce7); color: var(--success); }
.da-check-bad { border: 1px solid var(--danger); background: var(--danger-weak); color: var(--danger); }
.da-live { border: 1px solid var(--border); background: var(--surface-2, var(--surface)); color: var(--text); }
.da-banner-ok { margin-bottom: 14px; border: 1px solid var(--success); background: var(--success-weak, #dcfce7); color: var(--success); }
@media (max-width: 760px) {
  .da-grid { grid-template-columns: 1fr; }
  .da-stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- v1.33 「从产品库选品」搜索 / 分类筛选 ----------
   追加在末尾并用 :where() 保持 0 特异性（项目 UI 约定），避免覆盖 quote.css
   里选品弹窗的既有布局规则；这些 class 全是新增，无冲突。 */
:where(.q2-pick-toolbar) { flex-wrap: wrap; }
:where(.q2-pick-search) { flex: 1 1 260px; min-width: 180px; }
:where(.q2-pick-search input) { width: 100%; }
:where(.q2-pick-cat) { flex: 0 1 180px; min-width: 140px; }
:where(.q2-pick-cat select) { width: 100%; }
:where(.q2-pick-count) { display: block; margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
:where(.q2-pick-empty), :where(.q2-pick-more) {
  padding: 18px 14px; text-align: center; font-size: 12.5px; color: var(--muted);
}
:where(.q2-pick-more) { border-top: 1px solid var(--border); background: var(--surface-alt); }
/* 同一 .field 内搜索框与下拉各占一行（两者默认 width:100% 会自动换行），补一点间距。 */
:where(.q2-prd-kw) { margin-bottom: 8px; }
@media (max-width: 640px) {
  :where(.q2-pick-search), :where(.q2-pick-cat) { flex: 1 1 100%; }
}

/* ================= 网站新闻编辑（v1.65） ================= */
.sn-filters {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-alt);
}
.sn-filters input { flex: 1 1 220px; min-width: 160px; padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.sn-filters select { padding: 7px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); }
.sn-table-list th:first-child, .sn-table-list td:first-child { width: 86px; }
.sn-table-list th:nth-child(4), .sn-table-list td:nth-child(4) { width: 132px; }
.sn-table-list th:nth-child(5), .sn-table-list td:nth-child(5) { width: 128px; }
.sn-table-list th:nth-child(6), .sn-table-list td:nth-child(6) { width: 64px; }
.sn-table-list td { vertical-align: top; }
.sn-thumb-cell img { width: 76px; height: 46px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); display: block; }
.sn-thumb-empty { width: 76px; height: 46px; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); border-radius: 6px; color: var(--muted); font-size: 12px; }
.sn-title-cell strong { display: block; margin-bottom: 2px; }
.sn-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.sn-cat { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-alt); border: 1px solid var(--border); font-size: 12px; color: var(--text-sub); }
.sn-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 5px; }
.sn-tag { font-size: 11.5px; color: var(--primary, #2563eb); background: rgba(37, 99, 235, .08); border-radius: 4px; padding: 1px 6px; }
.sn-row-ops .btn { margin: 0 4px 4px 0; }

.sn-editor { display: flex; flex-direction: column; gap: 0; }
.sn-editor-head {
  position: sticky; top: 0; z-index: 6;
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 12px;
}
.sn-head-left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.sn-head-title { display: flex; align-items: center; gap: 8px; }
.sn-head-title h3 { margin: 0; font-size: 16px; }
.sn-head-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.sn-save-state { font-size: 12.5px; color: var(--muted); margin-right: 4px; }
.sn-draft-bar {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  padding: 10px 14px; margin-bottom: 12px; border: 1px dashed var(--primary, #2563eb);
  border-radius: var(--radius-sm); background: rgba(37, 99, 235, .06); font-size: 13px;
}
.sn-editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 336px; gap: 14px; align-items: start; }
.sn-editor-main, .sn-editor-side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.sn-editor-side { position: sticky; top: 76px; }
.sn-editor .fieldset { margin: 0; padding: 14px 16px 16px; background: var(--surface); }
.sn-editor .field { margin-bottom: 12px; }
.sn-editor .field:last-child { margin-bottom: 0; }
.sn-title-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.sn-editor .field.has-error input, .sn-editor .field.has-error select,
.sn-editor .field.has-error textarea { border-color: var(--danger); }
.sn-editor .field.has-error .field-err { display: block; }
.sn-editor-foot {
  display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center;
  margin-top: 14px; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
}
.sn-editor-foot .row { display: flex; gap: 8px; }

.sn-lang-tabs { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.sn-lang-tab {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface); color: var(--text-sub); cursor: pointer; font-size: 13px;
}
.sn-lang-tab.is-active { background: var(--primary, #2563eb); border-color: var(--primary, #2563eb); color: #fff; }
.sn-count { margin-left: auto; font-size: 12.5px; color: var(--muted); }
.sn-rt-editor { border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.sn-rt-editor:focus-within { border-color: var(--primary, #2563eb); box-shadow: var(--ring, 0 0 0 3px rgba(37, 99, 235, .15)); }
.sn-toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 3px;
  padding: 6px 8px; border-bottom: 1px solid var(--border); background: var(--surface-alt);
  position: sticky; top: 0; z-index: 2;
}
.sn-tool {
  min-width: 30px; height: 28px; padding: 0 7px; border: 1px solid transparent; border-radius: 5px;
  background: transparent; color: var(--text-sub); cursor: pointer; font-size: 12.5px; line-height: 1;
}
.sn-tool:hover { background: var(--surface); border-color: var(--border); color: var(--text); }
.sn-tool-select {
  height: 28px; padding: 0 6px; border: 1px solid var(--border); border-radius: 5px;
  background: var(--surface); color: var(--text-sub); font-size: 12.5px;
}
.sn-tool-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
.sn-rt-content {
  min-height: 420px; max-height: 70vh; overflow-y: auto; padding: 16px 18px;
  outline: none; line-height: 1.8; font-size: 14.5px; color: var(--text);
  word-break: break-word;
}
.sn-rt-content:empty::before { content: attr(data-placeholder); color: var(--muted); pointer-events: none; }
.sn-rt-content h2 { font-size: 20px; margin: 18px 0 8px; }
.sn-rt-content h3 { font-size: 17px; margin: 16px 0 8px; }
.sn-rt-content h4 { font-size: 15px; margin: 14px 0 6px; }
.sn-rt-content p { margin: 0 0 10px; }
.sn-rt-content blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--primary, #2563eb); background: var(--surface-alt); color: var(--text-sub); }
.sn-rt-content pre { margin: 12px 0; padding: 12px 14px; background: #0f172a; color: #e2e8f0; border-radius: 6px; overflow-x: auto; }
.sn-rt-content pre code { background: none; color: inherit; padding: 0; }
.sn-rt-content code { padding: 1px 5px; background: var(--surface-alt); border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.sn-rt-content ul, .sn-rt-content ol { margin: 0 0 10px; padding-left: 26px; }
.sn-rt-content img, .sn-rt-content video { max-width: 100%; height: auto; border-radius: 6px; margin: 8px 0; }
.sn-rt-content a { color: var(--primary, #2563eb); text-decoration: underline; }
.sn-rt-content table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.sn-rt-content table td, .sn-rt-content table th { border: 1px solid var(--border-strong); padding: 7px 10px; min-width: 60px; }
.sn-rt-content table th { background: var(--surface-alt); }
.sn-rt-content hr { border: 0; border-top: 1px solid var(--border); margin: 18px 0; }
.sn-rt-foot { display: flex; justify-content: space-between; gap: 10px; margin-top: 8px; flex-wrap: wrap; }

.sn-cover { margin-bottom: 14px; }
.sn-cover:last-child { margin-bottom: 0; }
.sn-cover-preview {
  display: flex; align-items: center; justify-content: center;
  height: 120px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface-alt); overflow: hidden; margin-bottom: 8px;
}
.sn-cover-preview.is-empty { border-style: dashed; color: var(--muted); font-size: 13px; }
.sn-cover-preview img { width: 100%; height: 100%; object-fit: cover; }
.sn-cover-ops { display: flex; gap: 8px; }

.sn-switch-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.sn-switch { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.sn-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.sn-switch-track {
  position: relative; width: 36px; height: 20px; border-radius: 999px;
  background: var(--border-strong); transition: background .16s ease; flex: none;
}
.sn-switch-track::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px;
  border-radius: 50%; background: #fff; transition: transform .16s ease;
}
.sn-switch input:checked + .sn-switch-track { background: var(--primary, #2563eb); }
.sn-switch input:checked + .sn-switch-track::after { transform: translateX(16px); }
.sn-switch input:focus-visible + .sn-switch-track { box-shadow: var(--ring, 0 0 0 3px rgba(37, 99, 235, .2)); }

.sn-preview { padding: 4px 2px 10px; }
.sn-preview h1 { font-size: 24px; line-height: 1.4; margin: 0 0 8px; }
.sn-preview-sub { color: var(--text-sub); font-size: 15px; margin: 0 0 10px; }
.sn-preview-meta { color: var(--muted); font-size: 12.5px; padding-bottom: 12px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.sn-preview-body { line-height: 1.85; font-size: 14.5px; }
.sn-preview-body h2 { font-size: 20px; margin: 18px 0 8px; }
.sn-preview-body h3 { font-size: 17px; margin: 16px 0 8px; }
.sn-preview-body blockquote { margin: 12px 0; padding: 8px 14px; border-left: 3px solid var(--primary, #2563eb); background: var(--surface-alt); }
.sn-preview-body pre { padding: 12px 14px; background: #0f172a; color: #e2e8f0; border-radius: 6px; overflow-x: auto; }
.sn-preview-body img, .sn-preview-body video { max-width: 100%; height: auto; border-radius: 6px; }
.sn-preview-body table { border-collapse: collapse; width: 100%; margin: 12px 0; }
.sn-preview-body th, .sn-preview-body td { border: 1px solid var(--border-strong); padding: 7px 10px; }

@media (max-width: 1180px) {
  .sn-editor-body { grid-template-columns: minmax(0, 1fr); }
  .sn-editor-side { position: static; }
  .sn-editor-head { position: static; }
}
@media (max-width: 720px) {
  .sn-editor-head, .sn-editor-foot { align-items: stretch; }
  .sn-head-left, .sn-head-actions { width: 100%; }
  .sn-head-left { flex-wrap: wrap; }
  .sn-head-actions .btn { flex: 1 1 auto; }
  .sn-title-row { grid-template-columns: minmax(0, 1fr); }
  .sn-editor-foot .row { width: 100%; }
  .sn-editor-foot .row .btn { flex: 1 1 auto; }
  .sn-rt-content { min-height: 300px; padding: 12px; }
  .sn-filters input, .sn-filters select { flex: 1 1 100%; }
  .sn-filters .btn { flex: 1 1 auto; }
  .sn-table-list th:nth-child(6), .sn-table-list td:nth-child(6) { display: none; }
}
