/* ============================================================
   报价单系统 · 设计令牌 + 基础组件样式
   主题 V2：暖色经营报表风 —— 奶油底 / 白色大圆角卡片 / 橙色主色 /
   超粗大数字 / 红色涨幅 / 荧光笔标题（参照 2026-10-02 风格参考图）
   ============================================================ */

/* ---------------- 1. 设计令牌 ---------------- */
:root {
  /* 品牌色（黑：极简黑白主题） */
  --c-primary: #191919;
  --c-primary-hover: #000000;
  --c-primary-active: #333333;
  --c-primary-soft: #F1F1EF;
  --c-primary-line: #E0E0DE;
  --grad-pri: linear-gradient(135deg, #4A4A4A 0%, #191919 100%);
  --grad-ribbon: linear-gradient(90deg, #6B6B68 0%, #2A2A2A 100%);
  --hl-marker: linear-gradient(90deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0)); /* 荧光笔 */

  /* 中性色 */
  --c-bg: #FFFFFF;
  --c-surface: #FFFFFF;
  --c-surface-soft: #F7F7F5;
  --c-surface-sunken: #F1F1EF;
  --c-line: #EDEDEB;
  --c-line-strong: #E0E0DE;
  --c-text: #1A1D21;
  --c-text-1: #141414; /* 主标题/重点文字色（web.css fallback 引用） */
  --c-text-2: #5F5F5C;
  --c-text-3: #8F8F8B;
  --c-text-off: #C9C9C5;
  --c-card: #FFFFFF; /* 卡片背景色 */

  /* 语义色 */
  --c-success: #16A34A;
  --c-success-bg: #E8F7EE;
  --c-success-line: #B7E4C7;
  --c-warn: #D97706;
  --c-warn-bg: #FEF3C7;
  --c-danger: #DC2626;
  --c-danger-bg: #FEF2F2;
  --c-void: #9CA3AF; /* 作废：仅名称灰字，卡片背景不变 */

  /* 圆角（V2 加大） */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 8px;
  --r-lg: 10px;
  --r-xl: 12px;

  /* 间距 */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s7: 32px;

  /* 字号 */
  --f11: 11px;
  --f12: 12px;
  --f13: 13px;
  --f14: 14px;
  --f16: 16px;
  --f18: 18px;
  --f20: 20px;
  --f24: 24px;
  --f28: 28px;

  /* 阴影（暖色调柔和） */
  --sh1: 0 1px 2px rgba(0, 0, 0, .05);
  --sh2: 0 4px 14px rgba(0, 0, 0, .07);
  --sh3: 0 14px 36px rgba(0, 0, 0, .14);

  /* 控件高度 */
  --h-ctl: 32px;
  --h-ctl-sm: 28px;

  /* 字体 */
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
}

/* ---------------- 2. Reset ---------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--f14);
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: inherit; text-decoration: none; }
table { border-collapse: collapse; width: 100%; }
img { display: block; max-width: 100%; }

.ico { flex: none; display: block; }

.num { font-variant-numeric: tabular-nums; }

/* 细滚动条（PC） */
.scroll-y { overflow-y: auto; overscroll-behavior: contain; }
.scroll-y::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-y::-webkit-scrollbar-thumb { background: #D7D9DE; border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
.scroll-y::-webkit-scrollbar-thumb:hover { background: #BFC3CA; background-clip: content-box; }
.scroll-y::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 3. 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--h-ctl);
  padding: 0 12px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  color: var(--c-text);
  font-size: var(--f13);
  font-weight: 500;
  white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
  user-select: none;
}

.btn:hover { border-color: var(--c-text-3); background: var(--c-surface-soft); }
.btn:active { background: var(--c-surface-sunken); }

.btn-primary {
  background: var(--c-primary);
  border-color: var(--c-primary);
  color: #fff;
}
.btn-primary:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); }
.btn-primary:active { background: var(--c-primary-active); }

.btn-soft {
  background: var(--c-primary-soft);
  border-color: var(--c-primary-line);
  color: var(--c-primary);
}
.btn-soft:hover { background: #E3ECFF; }

.btn-ghost { background: transparent; border-color: transparent; color: var(--c-text-2); }
.btn-ghost:hover { background: var(--c-surface-sunken); color: var(--c-text); }

.btn-danger { background: var(--c-surface); border-color: #F3C9C9; color: var(--c-danger); }
.btn-danger:hover { background: var(--c-danger-bg); border-color: #E8AFAF; }

.btn-sm { height: var(--h-ctl-sm); padding: 0 10px; font-size: var(--f12); }
.btn-xs { height: 24px; padding: 0 8px; font-size: var(--f12); border-radius: var(--r-sm); gap: 4px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 图标按钮 */
.ibtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--r-md);
  color: var(--c-text-2);
  transition: background .12s, color .12s;
}
.ibtn:hover { background: var(--c-surface-sunken); color: var(--c-primary); }
.ibtn.is-danger:hover { background: var(--c-danger-bg); color: var(--c-danger); }
.ibtn:disabled { opacity: .35; cursor: not-allowed; }

/* 文字链接按钮 */
.lnk { color: var(--c-primary); font-size: var(--f13); }
.lnk:hover { text-decoration: underline; }

/* ---------------- 4. 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font-size: var(--f12); color: var(--c-text-2); }
.label .req { color: var(--c-danger); margin-left: 2px; }

.input, .select, .textarea {
  width: 100%;
  height: var(--h-ctl);
  padding: 0 10px;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  font-size: var(--f13);
  outline: none;
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(25, 25, 25, .12);
}
.input::placeholder, .textarea::placeholder { color: var(--c-text-off); }
.input[readonly] { background: var(--c-surface-sunken); color: var(--c-text-2); }
.textarea { height: auto; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.select {
  appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7280' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='m6 9 6 6 6-6'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.input-inline { height: 26px; padding: 0 6px; font-size: var(--f13); border-radius: var(--r-sm); }
.input-num { text-align: right; font-variant-numeric: tabular-nums; }

.checkbox {
  appearance: none;
  width: 15px; height: 15px;
  border: 1.5px solid var(--c-line-strong);
  border-radius: var(--r-xs);
  background: #fff;
  cursor: pointer;
  flex: none;
  position: relative;
  transition: background .12s, border-color .12s;
}
.checkbox:checked { background: var(--c-primary); border-color: var(--c-primary); }
.checkbox:checked::after {
  content: "";
  position: absolute; left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: 2px solid #fff; border-top: 0; border-left: 0;
  transform: rotate(42deg);
}
.checkbox:indeterminate { background: var(--c-primary); border-color: var(--c-primary); }
.checkbox:indeterminate::after {
  content: "";
  position: absolute; left: 3px; top: 6px;
  width: 7px; height: 0; border-top: 2px solid #fff;
}

/* ---------------- 5. 卡片 / 分区 ---------------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r-lg);
}
.card-pad { padding: var(--s4); }
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  padding: 12px var(--s4);
  border-bottom: 1px solid var(--c-line);
}
.card-title { font-size: var(--f14); font-weight: 600; }
.card-sub { font-size: var(--f12); color: var(--c-text-2); }

.sec-title {
  display: flex; align-items: center; gap: 8px;
  font-size: var(--f14); font-weight: 600;
}
.sec-title::before {
  content: ""; width: 3px; height: 14px;
  background: var(--c-primary); border-radius: 2px;
}

/* 分段控件 */
.seg {
  display: inline-flex;
  border: 1px solid var(--c-line-strong);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--c-surface);
}
.seg > button {
  height: var(--h-ctl-sm);
  padding: 0 12px;
  font-size: var(--f12);
  color: var(--c-text-2);
  border-right: 1px solid var(--c-line);
}
.seg > button:last-child { border-right: 0; }
.seg > button.on { background: var(--c-primary-soft); color: var(--c-primary); font-weight: 600; }

/* 筛选 chip */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 10px;
  border: 1px solid var(--c-line);
  border-radius: 999px;
  background: var(--c-surface);
  font-size: var(--f12);
  color: var(--c-text-2);
  white-space: nowrap;
}
.chip.on {
  background: var(--c-primary-soft);
  border-color: var(--c-primary-line);
  color: var(--c-primary);
  font-weight: 600;
}
.chip .cnt { font-size: var(--f11); opacity: .75; }

/* ---------------- 6. 状态样式（报价单三态，全局统一） ---------------- */
.st {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: var(--r-sm);
  font-size: var(--f12);
  font-weight: 500;
  white-space: nowrap;
}
.st-talk { background: var(--c-surface-sunken); color: var(--c-text-2); }      /* 谈单中：默认 */
.st-deal { background: var(--c-success-bg); color: var(--c-success); }          /* 已成交：绿色 */
.st-void { background: var(--c-surface-sunken); color: var(--c-void); }         /* 作废 */

/* 已成交：卡片/行使用绿色背景 */
.is-deal { background: var(--c-success-bg) !important; }
.is-deal:hover { background: #DEF2E6 !important; }
/* 作废：仅名称灰字，背景保持默认 */
.is-void .q-name { color: var(--c-void); }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  height: 20px; padding: 0 6px;
  border: 1px solid var(--c-line);
  border-radius: var(--r-sm);
  font-size: var(--f11);
  color: var(--c-text-2);
  background: var(--c-surface-soft);
}

/* ---------------- 7. 表格 ---------------- */
.tbl { font-size: var(--f13); }
.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  height: 38px;
  padding: 0 10px;
  background: var(--c-surface-soft);
  border-bottom: 1px solid var(--c-line);
  font-size: var(--f12);
  font-weight: 600;
  color: var(--c-text-2);
  text-align: left;
  white-space: nowrap;
}
.tbl tbody td {
  height: 46px;
  padding: 0 10px;
  border-bottom: 1px solid var(--c-line);
  vertical-align: middle;
}
.tbl tbody tr:hover { background: var(--c-surface-soft); }
.tbl .ta-r { text-align: right; }
.tbl .ta-c { text-align: center; }
.tbl .money { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------------- 8. 空状态 / 提示 ---------------- */
.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; padding: 48px 16px; color: var(--c-text-3); font-size: var(--f13);
}
.empty svg { color: #D8DBE0; }

.toast-wrap {
  position: fixed; left: 50%; bottom: 40px; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  z-index: 9999; pointer-events: none;
}
.toast {
  display: inline-flex; align-items: center; gap: 8px;
  max-width: 80vw;
  padding: 9px 14px;
  border-radius: var(--r-md);
  background: #2B3242;
  color: #fff;
  font-size: var(--f13);
  box-shadow: var(--sh2);
  animation: toast-in .18s ease-out;
}
.toast.ok { background: #17693B; }
.toast.err { background: #A32222; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------- 9. 工具类 ---------------- */
.row { display: flex; align-items: center; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.g4 { gap: 4px; } .g6 { gap: 6px; } .g8 { gap: 8px; } .g12 { gap: 12px; } .g16 { gap: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }
.muted { color: var(--c-text-2); }
.dim { color: var(--c-text-3); }
.strong { font-weight: 600; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.hide { display: none !important; }
.divider { height: 1px; background: var(--c-line); }

/* 拖动排序中的全局兜底（sortable.js 拖动时给 body 加 .is-sorting） */
.is-sorting { user-select: none; -webkit-user-select: none; }
.is-sorting * { cursor: grabbing !important; }
