:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --line: #e6ebf3;
  --line-2: #dfe5ef;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;
  --primary: #2563eb;
  --primary-d: #1d4ed8;
  --primary-l: #eff4ff;
  --success: #16a34a;
  --warn: #f59e0b;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 10px 26px -16px rgba(16, 24, 40, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }
input, select, textarea { font-family: inherit; color: var(--text); }

.boot { display: flex; height: 100vh; align-items: center; justify-content: center; color: var(--muted); font-size: 14px; }

/* ---------------- 登录 ---------------- */
.login-scene {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% 8%, #e8f0ff 0%, rgba(232, 240, 255, 0) 60%),
    radial-gradient(700px 500px at 88% 92%, #eafaf1 0%, rgba(234, 250, 241, 0) 62%),
    #f6f8fc;
}
.login-card {
  width: 390px;
  max-width: 100%;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 34px 32px 26px;
  box-shadow: 0 24px 60px -30px rgba(15, 23, 42, 0.35);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 11px;
  background: linear-gradient(135deg, #2563eb, #4f7cf7);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; letter-spacing: 1px;
  box-shadow: 0 6px 16px -6px rgba(37, 99, 235, 0.7);
}
.login-brand h1 { font-size: 17px; margin: 0 0 3px; font-weight: 600; letter-spacing: 0.2px; }
.login-brand p { margin: 0; font-size: 12.5px; color: var(--muted); }
.login-form .fld { margin-bottom: 15px; }
.login-form .fld label { display: block; font-size: 12.5px; color: #475569; margin-bottom: 7px; font-weight: 500; }
.login-form input {
  width: 100%; height: 42px; border: 1px solid var(--line-2); border-radius: 9px;
  padding: 0 12px; font-size: 14px; background: #fbfcfe; transition: 0.15s;
}
.login-form input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3.5px rgba(37, 99, 235, 0.1); }
.login-btn {
  width: 100%; height: 42px; border: none; border-radius: 9px; cursor: pointer;
  background: var(--primary); color: #fff; font-size: 14.5px; font-weight: 500; margin-top: 6px;
  transition: 0.15s; box-shadow: 0 8px 18px -10px rgba(37, 99, 235, 0.9);
}
.login-btn:hover { background: var(--primary-d); }
.login-btn:disabled { opacity: 0.65; cursor: default; }
.login-err {
  margin-top: 12px; font-size: 13px; color: #b42318; background: #fef3f2;
  border: 1px solid #fecdca; border-radius: 8px; padding: 9px 11px; display: none;
}
.login-tip { margin-top: 18px; font-size: 12px; color: var(--muted-2); line-height: 1.7; text-align: center; }

/* ---------------- 布局 ---------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 234px; flex: 0 0 234px; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px 16px; }
.side-brand .brand-mark { width: 34px; height: 34px; border-radius: 9px; font-size: 15px; }
.side-brand .bt { font-size: 14px; font-weight: 600; line-height: 1.3; }
.side-brand .bs { font-size: 11.5px; color: var(--muted-2); }
.nav { padding: 6px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 9px;
  color: #3f4b5f; cursor: pointer; font-size: 13.5px; border: none; background: none; text-align: left; width: 100%;
  transition: 0.14s;
}
.nav-item:hover { background: #f5f8fd; color: var(--text); }
.nav-item.active { background: var(--primary-l); color: var(--primary-d); font-weight: 600; }
.nav-ico {
  width: 24px; height: 24px; border-radius: 7px; background: #f1f5fb; color: #64748b;
  display: flex; align-items: center; justify-content: center; font-size: 12px; flex: 0 0 24px;
}
.nav-item.active .nav-ico { background: #dbe7ff; color: var(--primary-d); }
.nav-badge {
  margin-left: auto; font-size: 11px; background: #eef2f8; color: var(--muted);
  padding: 1px 7px; border-radius: 999px; font-weight: 500;
}
.nav-item.active .nav-badge { background: #fff; color: var(--primary-d); }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--line); }
.user-box { display: flex; align-items: center; gap: 9px; padding: 6px 4px 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; background: #e8eefc; color: var(--primary-d);
  display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: 0 0 32px;
}
.user-box .un { font-size: 13px; font-weight: 600; line-height: 1.3; }
.user-box .ur { font-size: 11.5px; color: var(--muted-2); }
.side-foot .row { display: flex; gap: 6px; }
.side-foot .row .btn { flex: 1; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main#main { padding: 22px 26px 48px; width: 100%; max-width: 1500px; margin: 0 auto; }

.topbar { display: none; }

/* ---------------- 通用组件 ---------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h1 { font-size: 20px; margin: 0 0 5px; font-weight: 650; letter-spacing: 0.2px; }
.page-head .sub { margin: 0; font-size: 12.5px; color: var(--muted); }
.head-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: #fff; color: var(--text-2); font-size: 13.5px; cursor: pointer; white-space: nowrap;
  transition: 0.14s; font-weight: 500;
}
.btn:hover { background: #f8fafd; border-color: #cfd8e6; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 14px -9px rgba(37, 99, 235, 0.9); }
.btn.primary:hover { background: var(--primary-d); border-color: var(--primary-d); }
.btn.danger { color: var(--danger); border-color: #f3c9c9; }
.btn.danger:hover { background: #fef4f4; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { background: #f1f5fb; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card + .card { margin-top: 16px; }
.card-head { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--muted); }
.card-body { padding: 18px; }

.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); cursor: pointer; transition: 0.15s; position: relative; overflow: hidden;
}
.stat:hover { border-color: #cbd8ee; transform: translateY(-1px); }
.stat .lbl { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.stat .num { font-size: 23px; font-weight: 680; margin-top: 6px; letter-spacing: -0.4px; }
.stat .num small { font-size: 12px; font-weight: 500; color: var(--muted-2); margin-left: 4px; }
.stat.warn .num { color: #b45309; }
.stat.danger .num { color: var(--danger); }

.filter-bar {
  display: flex; gap: 9px; padding: 13px 16px; flex-wrap: wrap; align-items: center;
  background: #fbfcfe; border-bottom: 1px solid var(--line);
}
.search-wrap { position: relative; flex: 1 1 260px; min-width: 200px; }
.search-wrap .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted-2); font-size: 13px; }
.search-wrap input {
  width: 100%; height: 34px; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 0 11px 0 30px; font-size: 13.5px; background: #fff; transition: 0.14s;
}
.search-wrap input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.input, .select {
  height: 34px; border: 1px solid var(--line-2); border-radius: 8px; padding: 0 10px;
  font-size: 13.5px; background: #fff; color: var(--text-2); transition: 0.14s;
}
.input:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.select { padding-right: 26px; cursor: pointer; }
.filter-label { font-size: 12.5px; color: var(--muted); }
.filter-sep { width: 1px; height: 20px; background: var(--line); margin: 0 2px; }

.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  text-align: left; padding: 10px 14px; font-size: 12px; font-weight: 600; color: var(--muted);
  background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tbl td { padding: 11px 14px; border-bottom: 1px solid #f1f4f9; vertical-align: middle; }
table.tbl tbody tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover td { background: #fafcff; }
table.tbl tr.is-expired td { background: #fffaf9; }
table.tbl tr.is-expired:hover td { background: #fff5f3; }
table.tbl tr.is-deleted td { color: var(--muted); }
.cell-name { font-weight: 600; color: var(--text); cursor: pointer; }
.cell-name:hover { color: var(--primary); }
.cell-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.cell-muted { color: var(--muted); font-size: 13px; }
.ellip { max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .btn { height: 28px; padding: 0 9px; font-size: 12.5px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pill.green { background: #ecfdf3; color: #15803d; border: 1px solid #bbf7d0; }
.pill.blue { background: #eff6ff; color: #1d4ed8; border: 1px solid #dbeafe; }
.pill.amber { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.pill.red { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.pill.gray { background: #f4f6fa; color: #64748b; border: 1px solid #e5e9f0; }

.empty { padding: 56px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty p { margin: 0 0 14px; font-size: 13px; }

.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.pager .info { font-size: 12.5px; color: var(--muted); }
.pager .pages { display: flex; gap: 4px; align-items: center; }
.pg {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px; border: 1px solid var(--line-2);
  background: #fff; color: var(--text-2); font-size: 12.5px; cursor: pointer;
}
.pg:hover { background: #f5f8fd; }
.pg.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.pg:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.42); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 80;
  animation: fade 0.15s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 14px; width: 560px; max-width: 100%; max-height: 90vh;
  display: flex; flex-direction: column; box-shadow: 0 30px 70px -24px rgba(15, 23, 42, 0.5);
  animation: pop 0.16s ease;
}
@keyframes pop { from { transform: translateY(8px) scale(0.985); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.wide { width: 900px; }
.modal.mid { width: 680px; }
.modal-head { padding: 17px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal-head h2 { margin: 0 0 6px; font-size: 16.5px; font-weight: 650; }
.modal-head .tags { display: flex; gap: 6px; flex-wrap: wrap; }
.modal-head .sub { font-size: 12.5px; color: var(--muted); }
.x-btn { border: none; background: #f4f6fa; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; color: var(--muted); font-size: 16px; line-height: 1; flex: 0 0 30px; }
.x-btn:hover { background: #e9eef7; color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fbfcfe; flex-wrap: wrap; }
.modal-foot .meta { font-size: 12px; color: var(--muted-2); line-height: 1.6; }
.modal-foot .acts { display: flex; gap: 8px; }

/* ---------------- 表单 ---------------- */
.section-title { display: flex; align-items: center; gap: 8px; margin: 2px 0 13px; font-size: 13px; font-weight: 650; color: var(--text); }
.section-title::before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: var(--primary); }
.section-title .hint { font-size: 11.5px; font-weight: 400; color: var(--muted-2); margin-left: 4px; }
.form-section + .form-section { margin-top: 22px; padding-top: 18px; border-top: 1px dashed var(--line); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px 18px; }
.fld { min-width: 0; }
.fld.full { grid-column: 1 / -1; }
.fld label { display: block; font-size: 12.5px; color: #475569; margin-bottom: 6px; font-weight: 500; }
.fld label .req { color: var(--danger); margin-left: 2px; }
.fld .hint { font-size: 11.5px; color: var(--muted-2); margin-top: 4px; }
.fld input, .fld select, .fld textarea {
  width: 100%; border: 1px solid var(--line-2); border-radius: 8px; font-size: 13.5px;
  background: #fff; transition: 0.14s; color: var(--text);
}
.fld input, .fld select { height: 37px; padding: 0 10px; }
.fld textarea { padding: 9px 10px; min-height: 92px; line-height: 1.65; resize: vertical; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.09); }
.fld input.err, .fld textarea.err, .fld select.err { border-color: #f0a5a5; background: #fffafa; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 52px; }
.pw-eye { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: none; background: transparent; color: var(--muted); font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 5px; }
.pw-eye:hover { background: #f1f5fb; color: var(--text); }
.sensitive-note { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; font-size: 12.5px; padding: 10px 12px; border-radius: 9px; margin-bottom: 14px; line-height: 1.6; }

/* ---------------- 详情 ---------------- */
.detail-sec + .detail-sec { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 22px; }
.detail-grid .full { grid-column: 1 / -1; }
.ditem { min-width: 0; }
.ditem .dl { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; display: flex; align-items: center; gap: 5px; }
.ditem .dv { font-size: 13.5px; color: var(--text); line-height: 1.55; word-break: break-all; display: flex; align-items: center; gap: 7px; }
.ditem .dv.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.ditem .dv.empty { color: var(--muted-2); }
.ditem .dv.pre { white-space: pre-wrap; display: block; }
.copy-btn { border: 1px solid var(--line-2); background: #fff; border-radius: 6px; font-size: 11.5px; color: var(--muted); padding: 1px 6px; cursor: pointer; flex: 0 0 auto; }
.copy-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-l); }
.lockhint { font-size: 12px; color: var(--muted-2); }
.att-list { display: flex; flex-direction: column; gap: 8px; }
.att-item { display: flex; align-items: center; gap: 9px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; }
.att-item .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-item .sz { color: var(--muted-2); font-size: 11.5px; }
.att-item .thumb { width: 34px; height: 34px; border-radius: 6px; object-fit: cover; border: 1px solid var(--line); }

/* ---------------- 设置 ---------------- */
.set-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding: 14px 0; border-bottom: 1px solid #f1f4f9; }
.set-row:last-child { border-bottom: none; }
.set-row .t { font-size: 13.5px; font-weight: 500; }
.set-row .d { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.6; max-width: 620px; }
.switch { position: relative; width: 42px; height: 24px; flex: 0 0 42px; }
.switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.switch span { position: absolute; inset: 0; background: #d6dde8; border-radius: 999px; cursor: pointer; transition: 0.16s; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: 0.16s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(18px); }
.field-cfg-table td { padding: 8px 12px; }
.field-cfg-table .grp td { background: #f8fafc; font-weight: 600; font-size: 12.5px; color: var(--text-2); }
.grp-tip { margin-left: 8px; font-weight: 400; font-size: 11.5px; color: var(--muted-2); }

/* ---- 字段拖拽排序 ---- */
.field-cfg-table thead th.drag-th,
.field-cfg-table td.drag-cell { width: 34px; padding-left: 6px; padding-right: 0; }
.drag-handle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 26px; border-radius: 6px;
  color: var(--muted-2); font-size: 15px; line-height: 1;
  cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none;
}
.drag-handle:hover { background: var(--primary-l); color: var(--primary); }
.drag-handle:active { cursor: grabbing; }
tr.drag-src td { opacity: 0.4; background: var(--primary-l); }
.drag-ghost {
  position: fixed; z-index: 9999; display: flex; align-items: center; gap: 8px;
  padding: 9px 12px; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(15, 23, 42, 0.18);
  font-size: 13px; color: var(--text); pointer-events: none; user-select: none;
}
.drag-ghost .grip { color: var(--muted-2); }
body.is-dragging-field, body.is-dragging-field * { cursor: grabbing !important; }
body.is-dragging-field { user-select: none; -webkit-user-select: none; }
.order-hint { font-size: 12px; color: #b45309; align-self: center; }

.ck { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.ck:disabled { cursor: not-allowed; opacity: 1; accent-color: #93a3bd; }
.btn.danger-ghost { border-color: transparent; background: transparent; color: var(--danger); }
.btn.danger-ghost:hover { background: #fef4f4; border-color: #f3c9c9; }
.ck-line { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-2); min-height: 38px; }

/* 列设置：字段勾选网格 */
.col-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.col-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 11px;
  border: 1px solid var(--line); border-radius: 9px; font-size: 13px; cursor: pointer;
  background: #fcfdff;
}
.col-item:hover { border-color: #cfd8e6; background: #f8fafd; }
.col-item.fixed { background: #f4f7fc; color: var(--muted); cursor: default; }
.col-item .tag-soft { margin-left: auto; }
@media (max-width: 640px) { .col-grid { grid-template-columns: 1fr; } }
.hintbox { font-size: 12.5px; color: var(--muted); background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: 11px 13px; line-height: 1.7; }
.bk-list { display: flex; flex-direction: column; gap: 0; }

/* ---------------- 提示 ---------------- */
.toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: #101828; color: #fff; font-size: 13px; padding: 10px 14px; border-radius: 9px;
  box-shadow: 0 14px 30px -12px rgba(16, 24, 40, 0.6); animation: slideIn 0.18s ease; max-width: 340px;
}
.toast.ok { background: #05603a; }
.toast.err { background: #912018; }
@keyframes slideIn { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

.tag-soft { font-size: 11.5px; color: var(--muted); background: #f4f6fa; border-radius: 5px; padding: 1px 6px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1100px) {
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-102%); transition: transform 0.22s ease; box-shadow: 24px 0 50px -30px rgba(15,23,42,0.5); }
  .sidebar.open { transform: none; }
  .backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, 0.4); z-index: 39; display: none; }
  .backdrop.show { display: block; }
  .topbar {
    display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: #fff;
    border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30;
  }
  .topbar .tt { font-size: 14.5px; font-weight: 600; }
  .topbar .hamb { border: 1px solid var(--line-2); background: #fff; width: 34px; height: 34px; border-radius: 8px; font-size: 15px; cursor: pointer; color: var(--text-2); }
  main#main { padding: 14px 14px 60px; }
  .page-head h1 { font-size: 18px; }
  .form-grid, .detail-grid { grid-template-columns: 1fr; }
  .fld.full, .detail-grid .full { grid-column: auto; }
  .modal-mask { padding: 0; align-items: flex-end; }
  .modal, .modal.wide, .modal.mid { width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; }
  .ellip { max-width: 150px; }
  .filter-bar { padding: 11px 12px; }
  .filter-sep { display: none; }
  .stat { padding: 12px 13px; }
  .stat .num { font-size: 20px; }
  .card-head { padding: 13px 14px; }
  .card-body { padding: 14px; }
  .pager { padding: 10px 12px; }
}

/* ---------------- 导航分组（前台 / 后台） ---------------- */
.nav-group {
  padding: 14px 12px 5px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted-2);
  user-select: none;
}
.nav-group:first-child { padding-top: 4px; }

/* ---------------- 行内代码 ---------------- */
.hintbox code {
  background: #eef2f9;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-2);
  word-break: break-all;
}

/* ---------------- 移动端（H5）增强 ---------------- */
@media (hover: none) {
  button, .btn, a, .nav-item, .cell-name {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
  }
}

@media (max-width: 768px) {
  /* 输入控件 16px：避免 iOS 聚焦输入框时页面自动放大 */
  input, select, textarea, .input, .select { font-size: 16px; }
  /* 主要触控目标不小于 40px 高 */
  .btn { min-height: 40px; }
  .modal, .modal.wide, .modal.mid { max-height: 94dvh; }
  main#main { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }
  .modal-mask { padding-bottom: env(safe-area-inset-bottom); }
  .toast-wrap { left: 12px; right: 12px; top: calc(10px + env(safe-area-inset-top)); }
  .toast-wrap .toast { width: auto; }
}

/* 客户列表：手机上把表格转为卡片，避免横向滑动 */
@media (max-width: 820px) {
  .tbl-cust thead { display: none; }
  .tbl-cust, .tbl-cust tbody { display: block; }
  .tbl-cust tr {
    display: block;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px 14px;
    margin: 10px 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
  }
  .tbl-cust tr.is-expired { border-color: #fecaca; background: #fff8f8; }
  .tbl-cust tr.is-deleted { opacity: .72; }
  .tbl-cust td {
    display: flex; align-items: baseline; justify-content: space-between; gap: 14px;
    border: 0; padding: 5px 0; text-align: left; background: transparent;
  }
  .tbl-cust td::before {
    content: attr(data-th);
    flex-shrink: 0;
    font-size: 12.5px;
    color: var(--muted-2, #8a94a6);
  }
  .tbl-cust td.td-main { display: block; padding-bottom: 2px; }
  .tbl-cust td.td-main::before { content: none; }
  .tbl-cust td.td-actions {
    display: block;
    border-top: 1px dashed var(--line);
    margin-top: 8px; padding-top: 10px;
  }
  .tbl-cust td.td-actions::before { content: none; }
  .tbl-cust td.td-actions .row-actions { justify-content: flex-end; }
  .tbl-cust .ellip { max-width: none; white-space: normal; }
}

/* 手机卡片：隐藏次要字段，紧凑排版 */
@media (max-width: 820px) {
  .tbl-cust td[data-th="装机日期"],
  .tbl-cust td[data-th="负责员工"] { display: none; }
  .tbl-cust td[data-th="联系电话"],
  .tbl-cust td[data-th="门店地址"] { justify-content: flex-start; }
}

/* ---------------- 字段配置表：手机上转卡片式，避免类型列被压成竖排 ---------------- */
.ck-lbl { display: none; }

@media (max-width: 820px) {
  table.field-cfg-table thead { display: none; }
  table.field-cfg-table, table.field-cfg-table tbody { display: block; }
  table.field-cfg-table tbody { background: #fff; }
  table.field-cfg-table tr { display: block; }
  table.field-cfg-table tr.grp {
    padding: 10px 12px 8px;
    background: #f8fafc;
    border-top: 1px solid var(--line);
  }
  table.field-cfg-table tr.grp td { display: block; padding: 0; border: 0; background: transparent; }
  table.field-cfg-table tr.grp td .grp-tip { display: block; margin: 2px 0 0; }

  table.field-cfg-table tr[data-key] {
    display: grid;
    grid-template-columns: 26px auto auto auto 1fr;
    grid-template-areas:
      "grip name name name name"
      "grip d b l ."
      "grip ops ops ops ops";
    align-items: center;
    gap: 6px 12px;
    padding: 12px 12px 12px 10px;
    border-bottom: 1px solid var(--line);
  }
  table.field-cfg-table td { display: block; border: 0; padding: 0; background: transparent; }
  table.field-cfg-table td.drag-cell { grid-area: grip; align-self: stretch; display: flex; align-items: center; }
  table.field-cfg-table td.drag-cell .drag-handle { width: 24px; height: 30px; margin-left: -2px; }
  table.field-cfg-table td.fld-name { grid-area: name; font-size: 14px !important; line-height: 1.35; }
  table.field-cfg-table td.fld-type { display: none; }
  table.field-cfg-table td.ck-cell {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12.5px; color: var(--muted); text-align: left !important;
    padding-right: 4px;
  }
  table.field-cfg-table td.ck-cell:nth-of-type(4) { grid-area: d; }
  table.field-cfg-table td.ck-cell:nth-of-type(5) { grid-area: b; }
  table.field-cfg-table td.ck-cell:nth-of-type(6) { grid-area: l; }
  table.field-cfg-table .ck-lbl { display: inline; order: -1; }
  table.field-cfg-table .ck { width: 18px; height: 18px; }
  table.field-cfg-table td.fld-ops { grid-area: ops; }
  table.field-cfg-table td.fld-ops .row-actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; }
}

/* 筛选设置弹窗 */
.flt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
@media (max-width: 640px) { .flt-grid { grid-template-columns: 1fr; } }
.flt-item {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; cursor: pointer; font-size: 13.5px; color: var(--text-2);
}
.flt-item:hover { border-color: #c7d7f5; background: #f9fbff; }
.flt-item .ck { flex-shrink: 0; }
.flt-item span { flex: 1; }
.flt-tag { font-style: normal; font-size: 11px; color: var(--muted-2); background: #f4f6fa; border-radius: 5px; padding: 2px 6px; }
.filter-set { white-space: nowrap; }

/* 手机端字段配置卡片：去掉整行 hover 高亮造成的色块 */
@media (max-width: 820px) {
  table.tbl.field-cfg-table tbody tr:hover,
  table.tbl.field-cfg-table tbody tr:hover td { background: #fff; }
  table.tbl.field-cfg-table tr.grp:hover td { background: #f8fafc; }
}

/* ================================================================
 * 日常登记（类记事本）
 * ================================================================ */
.pill.purple { background: #f5f3ff; color: #6d28d9; border: 1px solid #ddd6fe; }
.pill.teal   { background: #f0fdfa; color: #0f766e; border: 1px solid #99f6e4; }

.note-title-line { display: flex; align-items: baseline; gap: 6px; min-width: 0; }
.note-star {
  border: none; background: none; padding: 0; cursor: pointer;
  font-size: 15px; line-height: 1; color: #cbd5e1; flex: 0 0 auto;
  transition: color .14s, transform .14s;
}
.note-star:hover { color: #f59e0b; transform: scale(1.12); }
.note-star.on { color: #f59e0b; }
.note-title { font-weight: 600; color: var(--text); cursor: pointer; word-break: break-word; }
.note-title:hover { color: var(--primary); }
.cell-link { color: var(--primary); cursor: pointer; }
.cell-link:hover { text-decoration: underline; }
.tbl-note td .cell-sub { max-width: 420px; }

.note-body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 14px;
  line-height: 1.85;
  color: #1f2937;
  min-height: 80px;
}
.note-empty { color: var(--muted-2); font-size: 13.5px; padding: 18px 0; }
.pill-link { cursor: pointer; }

/* 关联客户选择器 */
.pick-box { display: flex; flex-direction: column; gap: 8px; }
.pick-box > input {
  width: 100%; height: 37px; border: 1px solid var(--line-2); border-radius: 8px;
  padding: 0 10px; font-size: 13.5px; background: #fff;
}
.pick-box > input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .09); }
.pick-results {
  border: 1px solid var(--line-2); border-radius: 9px; background: #fff;
  max-height: 190px; overflow-y: auto;
}
.pick-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; padding: 9px 11px; border: none; border-bottom: 1px solid #f1f4f9;
  background: #fff; font-size: 13.5px; color: var(--text-2); cursor: pointer; text-align: left;
}
.pick-item:last-child { border-bottom: none; }
.pick-item:hover { background: #f6f9ff; color: var(--primary-d); }
.pick-item em { font-style: normal; font-size: 12px; color: var(--muted-2); flex: 0 0 auto; }
.pick-empty { padding: 12px; font-size: 12.5px; color: var(--muted-2); text-align: center; }
.pick-chosen { font-size: 13px; display: flex; align-items: center; gap: 8px; min-height: 24px; }
.pick-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--primary-l); border: 1px solid #dbe7ff; color: var(--primary-d);
  border-radius: 999px; padding: 3px 6px 3px 10px; font-size: 12.5px; font-weight: 500;
}
.pick-chip button {
  border: none; background: transparent; color: #64748b; cursor: pointer;
  font-size: 14px; line-height: 1; padding: 0 2px; border-radius: 50%;
}
.pick-chip button:hover { color: var(--danger); }

/* 分类管理 */
.cat-list { display: flex; flex-direction: column; gap: 8px; }
.cat-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 96px 54px auto;
  gap: 8px; align-items: center;
  padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; background: #fcfdff;
}
.cat-row .input, .cat-row .select { height: 34px; font-size: 13px; }
.cat-count { font-size: 12px; color: var(--muted-2); text-align: right; white-space: nowrap; }
.cat-add { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.cat-add .input { flex: 1 1 200px; min-width: 150px; }
.note-mine { font-size: 12.5px; color: var(--muted); }
.note-mine .ck { width: 15px; height: 15px; }

@media (max-width: 640px) {
  .cat-row { grid-template-columns: minmax(0, 1fr) 96px; grid-template-areas: "n c" "cnt ops"; }
  .cat-row .cat-name { grid-area: n; }
  .cat-row .cat-color { grid-area: c; }
  .cat-row .cat-count { grid-area: cnt; text-align: left; }
  .cat-row .row-actions { grid-area: ops; }
  .cat-row .row-actions .btn { height: 30px; }
}

/* 手机：登记列表卡片化后隐藏更新时间，摘要限制两行 */
@media (max-width: 820px) {
  .tbl-note td[data-th="更新时间"] { display: none; }
  .tbl-note td.td-main .cell-sub {
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden; margin-top: 4px;
  }
  .tbl-note td.td-main { padding-bottom: 4px; }
  .tbl-note td { font-size: 13.5px; }
  .note-star { font-size: 17px; padding: 2px 4px 2px 0; }
  .note-title { font-size: 14.5px; }
}

/* 表单里的勾选项：避免被 .fld input 的 100% 宽度/37px 高度撑大 */
.ck-line .ck { width: 16px; height: 16px; flex: 0 0 16px; }
#note-form textarea { min-height: 150px; }
@media (max-width: 820px) {
  #note-form textarea { min-height: 130px; max-height: 34vh; }
  /* 手机上筛选栏更紧凑：日期区间并排、隐藏「登记日期 / 至」文字 */
  .note-filter .note-date-label { display: none; }
  .note-filter .input[type="date"] { flex: 1 1 42%; min-width: 0; }
  .note-filter .filter-label + .input[type="date"] { flex-basis: 42%; }
}
