:root {
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e6eaf2;
  --text: #1c2434;
  --text-2: #5b6478;
  --text-3: #8b94a7;
  --primary: #2f6bff;
  --primary-soft: #edf2ff;
  --danger: #e5484d;
  --danger-soft: #fdeced;
  --warn: #b26a00;
  --warn-soft: #fff5e5;
  --ok: #0f8a5f;
  --ok-soft: #e7f7f0;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(19, 32, 61, .05), 0 8px 24px rgba(19, 32, 61, .05);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- 通用控件 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; white-space: nowrap; transition: .15s;
}
.btn:hover { border-color: #c9d3e8; background: #fafbff; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: #2559de; border-color: #2559de; }
.btn-danger { color: var(--danger); border-color: #f3c9cb; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #f0f3fa; color: var(--text); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .select {
  height: 34px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; outline: none; transition: .15s; min-width: 0;
}
.input:focus, .select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 107, 255, .12); }
.input::placeholder { color: #a9b2c3; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: radial-gradient(1200px 500px at 15% 0%, #e8eeff 0%, transparent 55%),
              radial-gradient(900px 500px at 100% 100%, #eaf7f2 0%, transparent 50%),
              var(--bg);
}
.login-card {
  width: 380px; background: var(--panel); border-radius: 18px; padding: 28px;
  box-shadow: 0 20px 60px rgba(28, 43, 80, .10), 0 2px 6px rgba(28, 43, 80, .06);
  border: 1px solid rgba(230, 234, 242, .9);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 22px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3f7bff, #1f4fd8); color: #fff;
  font-weight: 700; letter-spacing: .5px; box-shadow: 0 6px 16px rgba(47, 107, 255, .3);
}
.brand-title { font-size: 17px; font-weight: 650; }
.brand-sub { font-size: 12px; color: var(--text-3); }
.brand.small { margin-bottom: 18px; padding: 0 4px; }
.brand.small .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 12px; }
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.field .input, .field .select { width: 100%; height: 40px; }
.form-error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 8px; }
.demo-accounts { margin-top: 22px; border-top: 1px dashed var(--line); padding-top: 16px; }
.demo-title { font-size: 12px; color: var(--text-3); margin-bottom: 8px; }
.demo-list { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-list button {
  border: 1px solid var(--line); background: #fbfcff; border-radius: 8px;
  height: 32px; cursor: pointer; font-size: 12.5px; color: var(--text-2);
}
.demo-list button:hover { border-color: #bfd0ff; color: var(--primary); background: var(--primary-soft); }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100%; }
.sidebar {
  width: 216px; flex: 0 0 216px; background: #10192c; color: #cfd7e6;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand-title { color: #fff; font-size: 15px; }
.sidebar .side-foot { color: #8b97ad; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav button {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 38px; padding: 0 12px;
  border: 0; border-radius: 9px; background: transparent; color: #b9c4d6; cursor: pointer;
  font-size: 13.5px; text-align: left; transition: .15s;
}
.nav button:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav button.active { background: rgba(47, 107, 255, .22); color: #fff; box-shadow: inset 0 0 0 1px rgba(90, 140, 255, .35); }
.nav .ico { width: 16px; text-align: center; opacity: .85; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user-info { min-width: 0; }
.side-name { color: #eef2fa; font-size: 13px; }
.side-role { font-size: 11.5px; color: #8b97ad; }
.side-tip { font-size: 11px; color: #6d788e; line-height: 1.5; padding: 0 6px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: #23324e; color: #dfe7f7; font-size: 13px; flex: 0 0 32px;
}
.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.topbar h1 { font-size: 20px; font-weight: 650; margin: 0; }
.page-sub { margin: 2px 0 0; color: var(--text-3); font-size: 12.5px; }
.topbar-right { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; font-size: 12.5px; color: var(--text-2); }
.badge { border-radius: 999px; padding: 4px 10px; font-size: 12px; background: var(--primary-soft); color: var(--primary); }
.badge.own { background: var(--warn-soft); color: var(--warn); }

/* ---------- 卡片 / 统计 ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; color: var(--text-3); }
.stat .v { font-size: 21px; font-weight: 650; margin-top: 2px; letter-spacing: .3px; }
.stat .v small { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 4px; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden;
}
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1; }
.toolbar .input { width: 220px; }
.toolbar .select { width: auto; }
.hint { font-size: 12px; color: var(--text-3); }

/* ---------- 表格 ---------- */
.table-wrap { overflow: auto; }
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th {
  position: sticky; top: 0; z-index: 1; background: #f9fafd; color: var(--text-2);
  font-weight: 550; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.grid td { padding: 9px 12px; border-bottom: 1px solid #f0f3f9; vertical-align: middle; white-space: nowrap; }
table.grid tbody tr:hover td { background: #fbfcff; }
table.grid tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.muted { color: var(--text-3); }
td .lock { color: #c3cad8; font-size: 11px; margin-left: 4px; }

td.editable { cursor: cell; position: relative; }
td.editable:hover { background: #f3f7ff !important; box-shadow: inset 0 0 0 1px #d7e2ff; }
td.editable::after { content: ""; }
td.editable:hover .edit-dot { opacity: 1; }
.edit-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%; background: var(--primary);
  margin-left: 6px; opacity: 0; vertical-align: middle; transition: .15s;
}
td .cell-input { width: 100%; min-width: 90px; height: 26px; padding: 0 6px; border: 1px solid var(--primary); border-radius: 6px; outline: none; }

/* 订单表格：固定列宽 + 可拖拽调整 */
#order-table { table-layout: fixed; }
#order-table th { position: sticky; top: 0; z-index: 3; overflow: hidden; }
#order-table td { overflow: hidden; }
/* 表格区域内滚动，横向滚动条始终停留在页面可视区域底部 */
.table-scroll {
  overflow: auto;
  overscroll-behavior: contain;
}
/* 订单页：页面本身不滚动，表格撑满剩余高度，横向滚动条固定可见 */
body.orders-view .app { height: 100vh; }
body.orders-view .main { height: 100vh; display: flex; flex-direction: column; overflow: hidden; }
body.orders-view #view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.orders-view #view > .panel { flex: 1; min-height: 0; display: flex; flex-direction: column; }
body.orders-view .table-scroll { flex: 1; min-height: 0; }
.table-scroll::-webkit-scrollbar { width: 12px; height: 12px; }
.table-scroll::-webkit-scrollbar-track { background: #f1f4fa; border-radius: 6px; }
.table-scroll::-webkit-scrollbar-thumb { background: #c6cfdf; border-radius: 6px; border: 2px solid #f1f4fa; }
.table-scroll::-webkit-scrollbar-thumb:hover { background: #a9b5ca; }
#order-table th.sortable { cursor: pointer; user-select: none; }
#order-table th.sortable:hover { color: var(--primary); background: #f4f7ff; }
.sort-ind { font-size: 10px; color: var(--primary); margin-left: 4px; }
.col-resize {
  position: absolute; top: 0; right: -4px; width: 8px; height: 100%;
  cursor: col-resize; z-index: 2; border-radius: 2px;
}
.col-resize:hover, body.resizing .col-resize:active { background: rgba(47, 107, 255, .28); }
body.resizing { cursor: col-resize; user-select: none; }

/* 字段设置 */
.field-table .input { height: 28px; }
.field-table .code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12px;
  background: #f4f6fb; color: var(--text-2); padding: 1px 5px; border-radius: 4px;
}
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: 12px; background: #f1f3f9; color: var(--text-2); }
/* 销售商品状态：签收/已退回未退款/退货退款完结/换货进行中/换货完结/拒签/撤单/下架/整手回流 */
.pill.s1 { background: var(--ok-soft); color: var(--ok); }
.pill.s2 { background: var(--warn-soft); color: var(--warn); }
.pill.s3 { background: var(--danger-soft); color: var(--danger); }
.pill.s4 { background: var(--primary-soft); color: var(--primary); }
.pill.s5 { background: #e8f7f3; color: #0d7a63; }
.pill.s6 { background: #fff0e8; color: #b4531b; }
.pill.s7 { background: #f2f3f6; color: var(--text-3); }
.pill.s8 { background: #eef0f4; color: #6b7588; }
.pill.s9 { background: #f4efff; color: #6a3fd6; }
.pill.s0 { background: #f4f5f8; color: #9aa3b5; }
.thumb {
  width: 38px; height: 38px; object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line); background: #f6f8fc; display: block;
}
.img-empty {
  display: inline-grid; place-items: center; width: 38px; height: 38px;
  border-radius: 6px; border: 1px dashed #d8deea; color: #b3bbca; font-size: 11px;
}
.clip { display: inline-block; max-width: 180px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle; }
.row-actions { display: flex; gap: 6px; }

/* ---------- 空状态 ---------- */
.empty { padding: 48px 20px; text-align: center; color: var(--text-3); }
.empty .big { font-size: 30px; opacity: .35; }
.empty p { margin: 8px 0 0; font-size: 13px; }

/* ---------- 模态 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 25, 44, .44); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 50;
}
.modal {
  background: #fff; border-radius: 14px; width: 520px; max-width: 100%; max-height: 88vh;
  overflow: auto; box-shadow: 0 24px 70px rgba(10, 20, 40, .3);
  animation: pop .16s ease-out;
}
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: .6; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 620; }
.modal-body { padding: 16px 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-body .full { grid-column: 1 / -1; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px 18px; }
.modal .field { margin: 0; }
.modal-close { border: 0; background: transparent; font-size: 20px; color: var(--text-3); cursor: pointer; line-height: 1; padding: 4px; }

/* ---------- 日志 ---------- */
.diff { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.diff .old { color: var(--text-3); text-decoration: line-through; }
.diff .arrow { color: #b8c0d0; }
.diff .new { color: var(--ok); font-weight: 550; }
.act { display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px; }
.act-login { background: #f1f3f9; color: var(--text-2); }
.act-create { background: var(--ok-soft); color: var(--ok); }
.act-update { background: var(--primary-soft); color: var(--primary); }
.act-delete { background: var(--danger-soft); color: var(--danger); }
.act-export { background: #f4efff; color: #6a3fd6; }
.act-user, .act-role { background: var(--warn-soft); color: var(--warn); }
.log-meta { color: var(--text-3); font-size: 12px; }

/* ---------- 用户 / 权限 ---------- */
.switch { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text-2); }
.switch input { width: 15px; height: 15px; accent-color: var(--primary); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.role-card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.role-card header { padding: 14px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.role-card h3 { margin: 0; font-size: 14.5px; }
.role-card .desc { font-size: 12px; color: var(--text-3); }
.role-card .body { padding: 12px 16px; }
.role-card footer { margin-top: auto; padding: 10px 16px 14px; display: flex; justify-content: space-between; align-items: center; }
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 0; border-bottom: 1px dashed #f1f3f9; }
.perm-row:last-child { border-bottom: 0; }
.perm-row .pl { font-size: 13px; }
.perm-row .pl small { color: var(--text-3); font-size: 11.5px; margin-left: 4px; }
.perm-row .select { height: 30px; width: 92px; font-size: 12.5px; }
.opts { display: flex; flex-wrap: wrap; gap: 12px; padding: 4px 0 10px; border-bottom: 1px solid var(--line); margin-bottom: 8px; }
.section-title { font-size: 12px; color: var(--text-3); margin: 8px 0 4px; letter-spacing: .3px; }
.chk-line { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); padding: 3px 0; }

/* ---------- 提示 ---------- */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #16203a; color: #fff; padding: 9px 16px; border-radius: 9px; font-size: 13px;
  box-shadow: 0 10px 30px rgba(10, 20, 40, .25); animation: tin .18s ease-out; max-width: 70vw;
}
.toast.err { background: #b62b2f; }
.toast.ok { background: #0d7a54; }
@keyframes tin { from { transform: translateY(-8px); opacity: 0; } }

@media (max-width: 900px) {
  .sidebar { width: 64px; flex-basis: 64px; padding: 14px 8px; }
  .sidebar .brand-title, .side-name, .side-role, .side-tip, .nav button span.txt, .btn-block { display: none; }
  .nav button { justify-content: center; padding: 0; }
  .main { padding: 16px 14px 30px; }
  .toolbar .input { width: 100%; }
}
