:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --primary: #2b7fff;
  --primary-d: #1f63d6;
  --text: #1f2733;
  --muted: #8a94a6;
  --border: #e8ecf2;
  --ok: #1fb673;
  --warn: #f5a623;
  --danger: #f5455c;
  --sidebar: #1f2937;
  --sidebar-txt: #c3ccd9;
  --shadow: 0 2px 12px rgba(31, 39, 51, 0.06);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; }
a { color: inherit; text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #2b7fff 0%, #5b8def 100%); }
.login-card { width: 360px; background: #fff; border-radius: 14px; padding: 36px 32px; box-shadow: var(--shadow); }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 6px; }
.login-card .sub { text-align: center; color: var(--muted); margin-bottom: 24px; font-size: 13px; }
.login-card .hint { margin-top: 14px; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- 布局 ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 210px; background: var(--sidebar); color: var(--sidebar-txt); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar .brand { padding: 18px 20px; font-size: 17px; font-weight: 700; color: #fff; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar nav { padding: 10px 0; flex: 1; overflow-y: auto; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; padding: 11px 20px; font-size: 14px; cursor: pointer; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.sidebar nav a.active { background: rgba(43,127,255,.18); color: #fff; border-left-color: var(--primary); }
.sidebar .foot { padding: 14px 20px; font-size: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar .foot .name { color: #fff; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar { height: 56px; background: var(--panel); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; }
.topbar .title { font-size: 16px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; color: var(--muted); }
.content { padding: 22px; flex: 1; overflow-y: auto; }

/* ---------- 通用 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 18px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card h3 { font-size: 15px; margin-bottom: 14px; display: flex; align-items: center; justify-content: space-between; }
.fund-adjust { margin-top: 18px; border-left: 3px solid var(--accent); }
.fund-adjust h4 { font-size: 14px; margin-bottom: 6px; }
.fund-adjust .foot { margin-top: 12px; }
.pts-fields { grid-column: 1 / -1; margin-top: 6px; padding: 12px 14px; background: #fffaf2; border: 1px solid #ffe2b8; border-radius: 8px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.row.tight { gap: 8px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right-action { display: flex; gap: 8px; }

input, select, textarea { font-family: inherit; font-size: 14px; padding: 8px 11px; border: 1px solid var(--border); border-radius: 8px; background: #fff; color: var(--text); outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
label.f { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 5px; }

/* ---------- 按钮 ---------- */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 15px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text); cursor: pointer; font-size: 13px; transition: .15s; }
.btn:hover { border-color: var(--primary); color: var(--primary); }
.btn.primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-d); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); border-color: #f6c5cc; }
.btn.danger:hover { background: #fff0f2; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- 统计卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.stat .v { font-size: 24px; font-weight: 700; }
.stat .v.ok { color: var(--ok); }
.stat .v.warn { color: var(--warn); }
.stat .v.primary { color: var(--primary); }

/* ---------- 表格 ---------- */
.table-wrap { width: 100%; overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--panel); }
table { width: auto; min-width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { padding: 11px 12px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfc; }
tbody tr:hover { background: #f8fafc; }
td.wrap { white-space: normal; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: #eef3ff; color: var(--primary); }
.tag.green { background: #e8f8f0; color: var(--ok); }
.tag.gray { background: #f0f2f5; color: var(--muted); }
.tag.orange { background: #fff4e3; color: var(--warn); }
.tag.red { background: #ffecef; color: var(--danger); }
.li-inp { width: 150px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }

/* ---------- 分页 ---------- */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; margin-top: 14px; }

/* ---------- 弹窗 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; box-sizing: border-box; z-index: 50; }
.modal { width: 480px; max-width: 92vw; max-height: 90vh; overflow-y: auto; background: #fff; border-radius: 12px; padding: 22px; box-sizing: border-box; }
.modal.wide { width: 860px; }
.modal h3 { font-size: 16px; margin-bottom: 8px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

/* ---------- 角色权限编辑：权限树 ---------- */
.perm-tree { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.perm-group { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fbfcfe; }
.perm-group-title { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 8px; }
.perm-items { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.perm-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); cursor: pointer; }
.perm-item input { width: 15px; height: 15px; accent-color: var(--primary); }
.grid-row { display: grid; gap: 6px; align-items: center; margin-bottom: 6px; }
.grid-row input, .grid-row textarea { width: 100%; }
.perm-cell .tag { margin: 0 4px 4px 0; }
td.ops { white-space: nowrap; }
td.ops .btn { margin-right: 6px; }

/* ---------- 计算规则（分式） ---------- */
.formula { margin-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.fm { border: 1px solid var(--border); border-radius: 10px; padding: 11px 14px; background: #fbfcfe; }
.fm > b { color: var(--text); font-size: 14px; }
.fm-eq { margin-top: 6px; font-family: "SFMono-Regular", Consolas, Menlo, monospace; font-size: 13px; color: var(--primary); background: #eef3ff; border-radius: 6px; padding: 6px 10px; letter-spacing: .2px; }
.fm-note { margin-top: 6px; font-size: 12px; color: var(--muted); line-height: 1.6; }

/* ---------- 关系图 ---------- */
.rel-head { font-size: 13px; color: var(--text); background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; line-height: 1.7; }
.rel-head .upline { color: var(--muted); margin-top: 4px; }
.rel-head b { color: var(--primary); }
.graph-scroll { max-height: 60vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; background: #fcfdff; padding: 6px; }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.tabs a { padding: 10px 16px; font-size: 14px; cursor: pointer; border-bottom: 2px solid transparent; color: var(--muted); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* ---------- 杂项 ---------- */
.empty { text-align: center; color: var(--muted); padding: 40px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; }
.rp-sum { font-size: 13px; color: var(--muted); }
.rp-sum b { color: var(--text); margin: 0 2px; }
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 99; font-size: 13px; box-shadow: var(--shadow); }
.toast.ok { background: var(--ok); }
.toast.err { background: var(--danger); }
.bar-chart { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.bar-row .lbl { width: 90px; color: var(--muted); }
.bar-row .bar { flex: 1; height: 16px; background: #eef3ff; border-radius: 4px; overflow: hidden; }
.bar-row .bar i { display: block; height: 100%; background: var(--primary); }
.bar-row .num { width: 40px; text-align: right; }

/* ---------- 商品：图片网格 ---------- */
.img-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.img-thumb { position: relative; width: 84px; height: 84px; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; cursor: pointer; background: #fafbfc; flex: 0 0 auto; }
.img-thumb.main { width: 120px; height: 120px; border-color: var(--primary); }
.img-thumb img { width: 100%; height: 100%; object-fit: cover; }
.img-thumb .cover-badge { position: absolute; left: 0; top: 0; background: var(--primary); color: #fff; font-size: 11px; padding: 1px 6px; border-bottom-right-radius: 6px; }
.img-thumb .img-del { position: absolute; right: 2px; top: 2px; width: 18px; height: 18px; line-height: 16px; text-align: center; border: none; border-radius: 50%; background: rgba(15,23,42,.55); color: #fff; cursor: pointer; font-size: 13px; padding: 0; }

/* ---------- 商品：规格行 ---------- */
.spec-row { display: flex; gap: 8px; margin-bottom: 8px; align-items: center; }
.spec-row input { flex: 1; min-width: 0; }
.spec-row .sp-price, .spec-row .sp-stock { flex: 0 0 78px; }
#addSpec { margin-bottom: 14px; }

/* ---------- 商品：图文富文本 ---------- */
.rich-editor { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 6px; }
.rich-toolbar { display: flex; gap: 4px; padding: 6px 8px; background: #f7f9fc; border-bottom: 1px solid var(--border); }
.rich-toolbar button { border: 1px solid var(--border); background: #fff; border-radius: 6px; padding: 3px 9px; cursor: pointer; font-size: 13px; }
.rich-toolbar button:hover { border-color: var(--primary); color: var(--primary); }
.rich-area { min-height: 150px; padding: 12px; outline: none; font-size: 14px; line-height: 1.7; }
.rich-area img { max-width: 100%; border-radius: 6px; }

/* ---------- 系统设置：页面列表 ---------- */
.pg-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.pg-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.pg-handle { display: flex; flex-direction: column; gap: 2px; }
.pg-handle button { width: 26px; height: 20px; border: 1px solid var(--border); background: #f7f9fc; border-radius: 4px; cursor: pointer; font-size: 12px; line-height: 1; }
.pg-handle button:disabled { opacity: .4; cursor: not-allowed; }
.pg-key { font-size: 12px; color: #888; min-width: 56px; font-family: monospace; }
.pg-icon { width: 52px; text-align: center; font-size: 16px; }
.pg-name { flex: 1; min-width: 80px; }
.pg-show { display: flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 13px; }
