/* ============ 基础与通用组件（前后台共用） ============ */
:root {
  --ink: #151413; --ink-2: #1f1d1c; --ink-3: #2c2a28;
  --primary: #d4521c; --primary-600: #b94515; --primary-50: #fdf1ea; --primary-100: #f8dccb;
  --seal: #c9361f; --seal-50: #fdf0ec; --gold: #e8622a;
  --success: #12a150; --success-50: #e8f7ee; --warning: #d98a07; --warning-50: #fff6e5; --danger: #dc3a2f; --danger-50: #fdeeec;
  --text: #17202f; --text-2: #3f4a5c; --muted: #7a8496; --line: #e5e9f0; --line-2: #eef1f5;
  --bg: #f4f6fa; --card: #fff;
  --radius: 12px; --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 30, 60, .06);
  --shadow: 0 2px 6px rgba(15, 30, 60, .05), 0 8px 24px rgba(15, 30, 60, .06);
  --shadow-lg: 0 12px 40px rgba(15, 30, 60, .16);
  --serif: "Noto Serif SC", "Source Han Serif SC", "Songti SC", "STSong", "SimSun", serif;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; font-family: var(--font); font-size: 14px; line-height: 1.6; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
body.no-scroll { overflow: hidden; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.3; font-weight: 700; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.ic { flex-shrink: 0; vertical-align: middle; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* 按钮 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 18px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-size: 14px; font-weight: 500; cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .05s; user-select: none; background: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(212, 82, 28, .28); }
.btn-primary:hover:not(:disabled) { background: var(--primary-600); }
.btn-seal { background: var(--seal); color: #fff; box-shadow: 0 2px 8px rgba(200, 55, 45, .25); }
.btn-seal:hover:not(:disabled) { background: #b02e25; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.btn-soft { background: var(--primary-50); color: var(--primary); }
.btn-soft:hover:not(:disabled) { background: var(--primary-100); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #c22f25; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #0e8c45; }
.btn-text { background: none; color: var(--primary); padding: 0 6px; height: auto; }
.btn-text:hover { text-decoration: underline; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 46px; padding: 0 26px; font-size: 15px; }
.btn-block { width: 100%; }
.btn.loading { color: transparent !important; position: relative; }
.btn.loading::after { content: ''; position: absolute; width: 16px; height: 16px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
.btn-ghost.loading::after, .btn-soft.loading::after { border-color: var(--primary); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* 表单 */
.field { margin-bottom: 18px; }
.field > label, .label { display: block; font-size: 13px; color: var(--text-2); font-weight: 500; margin-bottom: 6px; }
.field .req { color: var(--danger); margin-left: 2px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 6px; }
.input, .select, textarea.input { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s; font-size: 14px; }
textarea.input { height: auto; padding: 10px 12px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(212, 82, 28, .14); }
.input::placeholder { color: #a8b0bd; }
.select { appearance: none; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237a8496' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center; padding-right: 32px; }
.input-group { display: flex; gap: 8px; }
.input-group .input { flex: 1; min-width: 0; }
.check { display: inline-flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.check input { margin: 3px 0 0; width: 15px; height: 15px; accent-color: var(--primary); }
.radio-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.radio-cards label { position: relative; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; cursor: pointer; text-align: center; font-size: 14px; transition: all .15s; background: #fff; }
.radio-cards input { position: absolute; opacity: 0; }
.radio-cards label:has(input:checked) { border-color: var(--primary); background: var(--primary-50); color: var(--primary); font-weight: 600; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }

/* 徽标/状态 */
.badge { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; background: var(--line-2); color: var(--text-2); }
.badge .ic { width: 12px; height: 12px; }
.b-pending, .b-warning { background: var(--warning-50); color: var(--warning); }
.b-approved, .b-success, .b-verified, .b-done, .b-replied, .b-active { background: var(--success-50); color: var(--success); }
.b-rejected, .b-danger, .b-disabled { background: var(--danger-50); color: var(--danger); }
.b-offline, .b-closed, .b-none { background: #eef0f3; color: #6b7280; }
.b-processing, .b-info { background: var(--primary-50); color: var(--primary); }
.b-seal { background: var(--seal-50); color: var(--seal); }

/* 提示条 */
.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: 13px; line-height: 1.6; align-items: flex-start; }
.alert .ic { margin-top: 2px; }
.alert-info { background: #f3f1ee; color: #4a4540; }
.alert-warning { background: var(--warning-50); color: #8a5600; }
.alert-success { background: var(--success-50); color: #0b6b36; }
.alert-danger { background: var(--danger-50); color: #9b231b; }

/* 卡片 */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow-sm); border: 1px solid var(--line-2); }
.card-pad { padding: 24px; }

/* Toast */
.toast-box { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { display: flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 10px; background: #fff; box-shadow: var(--shadow-lg); font-size: 14px; color: var(--text);
  opacity: 0; transform: translateY(-10px); transition: all .25s; border-left: 3px solid var(--primary); }
.toast.show { opacity: 1; transform: none; }
.toast-success { border-left-color: var(--success); } .toast-success .ic { color: var(--success); }
.toast-error { border-left-color: var(--danger); } .toast-error .ic { color: var(--danger); }
.toast-info .ic { color: var(--primary); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(11, 26, 49, .5); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px); }
.modal-mask.show { opacity: 1; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-height: calc(100vh - 40px); display: flex; flex-direction: column; box-shadow: var(--shadow-lg); transform: translateY(12px) scale(.98); transition: transform .2s; }
.modal-mask.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 22px; border-bottom: 1px solid var(--line-2); }
.modal-head h3 { font-size: 16px; }
.modal-x { border: 0; background: none; cursor: pointer; color: var(--muted); padding: 4px; border-radius: 6px; display: flex; }
.modal-x:hover { background: var(--line-2); color: var(--text); }
.modal-body { padding: 22px; overflow-y: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 10px; }
.confirm-msg { font-size: 15px; color: var(--text-2); margin-bottom: 12px; }

/* 分页 */
.pager { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 24px; flex-wrap: wrap; }
.pg { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.pg:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pg.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg:disabled { opacity: .4; cursor: not-allowed; }
.pg-gap { color: var(--muted); padding: 0 2px; }
.pg-total { color: var(--muted); font-size: 13px; margin-left: 8px; }

/* 空状态 / 加载 */
.empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.empty .ic { width: 44px; height: 44px; color: #c4cad4; margin-bottom: 10px; }
.empty p { font-size: 14px; }
.skeleton { background: linear-gradient(90deg, #eef1f5 25%, #f7f8fb 37%, #eef1f5 63%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.page-loading { display: flex; justify-content: center; padding: 80px 0; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--primary-100); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }

/* 表格 */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); background: #f7f9fc; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:hover td { background: #fafbfd; }
.table .ops { white-space: nowrap; display: flex; gap: 4px; flex-wrap: wrap; }

/* 描述列表 */
.desc { display: grid; grid-template-columns: 120px 1fr; border: 1px solid var(--line); border-radius: var(--radius-sm); overflow: hidden; font-size: 14px; }
.desc > div { padding: 11px 14px; border-bottom: 1px solid var(--line-2); }
.desc > div:nth-child(odd) { background: #f7f9fc; color: var(--muted); }
.desc > div:nth-last-child(-n+2) { border-bottom: 0; }

/* 上传 */
.uploader { display: flex; gap: 10px; flex-wrap: wrap; }
.up-item, .up-add { width: 96px; height: 96px; border-radius: var(--radius-sm); position: relative; overflow: hidden; }
.up-item img { width: 100%; height: 100%; object-fit: cover; }
.up-item button { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: rgba(0, 0, 0, .55); color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; padding: 0; }
.up-add { border: 1.5px dashed #c9d0dc; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); cursor: pointer; font-size: 12px; gap: 4px; background: #fafbfd; transition: all .15s; }
.up-add:hover { border-color: var(--primary); color: var(--primary); }
.up-add input { display: none; }

/* 小屏通用 */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .card-pad { padding: 18px; }
  .modal-mask { align-items: flex-end; padding: 0; }
  .modal { border-radius: 16px 16px 0 0; max-height: 92vh; }
  .modal-body { padding: 18px; }
  .desc { grid-template-columns: 96px 1fr; font-size: 13px; }
  .input, .select { height: 42px; font-size: 16px; } /* 避免 iOS 输入时自动缩放 */
  textarea.input { font-size: 16px; }
}
