:root {
  --brand: #6d5efc;
  --brand-2: #8b7bff;
  --brand-soft: #eef0ff;
  --bg: #f5f6fa;
  --panel: #ffffff;
  --text: #1f2430;
  --muted: #6b7280;
  --line: #eaecf2;
  --ok: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --info: #2563eb;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 36, 48, .06);
  --shadow-lg: 0 20px 50px rgba(31, 36, 48, .16);
  --sidebar-w: 236px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--text);
  padding: 9px 16px; border-radius: 10px; cursor: pointer; font-size: 13px;
  transition: .15s; white-space: nowrap; font-weight: 500;
}
.btn:hover { border-color: #d7dae4; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: #5b4cf0; border-color: #5b4cf0; }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); border-color: #f3c9c9; background: #fff5f5; }
.btn-danger:hover { background: #fee; }
.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 8px; }
.btn-block { width: 100%; }
.icon-btn { border: none; background: transparent; font-size: 20px; cursor: pointer; color: var(--text); padding: 4px 8px; border-radius: 8px; display: none; }
.icon-btn:hover { background: var(--brand-soft); }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #eceaff 0%, transparent 60%),
              radial-gradient(1000px 500px at 100% 100%, #e6f7ff 0%, transparent 55%), var(--bg);
  padding: 20px;
}
.login-card {
  width: 100%; max-width: 400px; background: var(--panel); border-radius: 18px;
  box-shadow: var(--shadow-lg); padding: 34px 30px;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; margin: 0; }
.login-brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .5px; }
.logo {
  width: 46px; height: 46px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-size: 22px; font-weight: 700; display: grid; place-items: center;
}
.login-form .field { display: block; margin-bottom: 16px; }
.field > span { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; background: #fafbfc; color: var(--text); outline: none; transition: .15s;
  font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px var(--brand-soft);
}
.field.invalid input, .field.invalid select { border-color: var(--danger); box-shadow: 0 0 0 3px #fde8e8; }
.login-err { color: var(--danger); font-size: 12px; margin: -6px 0 12px; }
.login-tip { text-align: center; color: var(--muted); font-size: 12px; margin: 14px 0 0; }
.login-extra { text-align: right; margin-top: 12px; }
.login-extra a { color: var(--brand); font-size: 13px; cursor: pointer; }
.forgot-tip { line-height: 1.9; color: var(--muted); text-align: center; padding: 10px 4px; font-size: 14px; }
.login-form .btn-block { margin-top: 6px; letter-spacing: 4px; }

/* ---------- App layout ---------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--panel); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; z-index: 40;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px; border-bottom: 1px solid var(--line); }
.sidebar-brand .logo { width: 34px; height: 34px; font-size: 17px; border-radius: 9px; }
.brand-text { font-weight: 700; font-size: 16px; }
.nav { flex: 1; overflow-y: auto; padding: 12px 12px; }
.nav-group { font-size: 12px; font-weight: 600; color: var(--muted); padding: 16px 14px 6px; letter-spacing: .5px; }
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px;
  color: var(--muted); font-weight: 600; font-size: 15px; margin-bottom: 4px;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
.nav-item .ic { width: 22px; text-align: center; font-style: normal; font-size: 17px; transition: transform .2s ease; }
.nav-item:hover { background: var(--brand-soft); color: var(--brand); transform: translateX(3px); }
.nav-item:hover .ic { transform: scale(1.15); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 700; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 62%; border-radius: 0 4px 4px 0; background: var(--brand);
}
.nav-item.active .ic { transform: scale(1.15); }
.sidebar-foot { padding: 12px; border-top: 1px solid var(--line); }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }

.main { flex: 1; min-width: 0; height: 100vh; overflow: hidden; display: flex; flex-direction: column; }
.topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; position: sticky; top: 0; z-index: 30;
}
.topbar h2 { font-size: 17px; margin: 0; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-style: normal; font-weight: 600; font-size: 13px; }
.role-tag { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }
.content { padding: 22px; flex: 1; overflow: auto; }

/* ---------- Cards / stat ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 18px; }
.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-card { background: var(--panel); border-radius: 12px; padding: 18px 20px; box-shadow: var(--shadow); border: 1px solid var(--line); transition: transform .18s ease, box-shadow .18s ease; }
.stat-card:hover { transform: translateY(-3px); box-shadow: 0 10px 24px rgba(0,0,0,.12); }
.stat-card .label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 8px; }
.stat-card .num { font-size: 28px; font-weight: 700; margin-top: 8px; font-variant-numeric: tabular-nums; }
.stat-card .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.stat-ic { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; font-style: normal; font-size: 15px; }
/* 标签页（商品库存 / 操作日志） */
.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--line); }
.tabs .tab { background: none; border: none; padding: 10px 18px; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; border-radius: 8px 8px 0 0; transition: color .15s; }
.tabs .tab:hover { color: var(--text); }
.tabs .tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel[hidden] { display: none; }
/* 仓库管理统计卡（稍大字体 + 美化） */
.stat-card .stat-label { color: var(--muted); font-size: 15px; font-weight: 600; letter-spacing: .3px; display: flex; align-items: center; gap: 9px; }
.stat-card .stat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c, #888); display: inline-block; flex: none; }
.stat-card .stat-value { font-size: 32px; font-weight: 800; margin-top: 12px; font-variant-numeric: tabular-nums; letter-spacing: .5px; }

.panel { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); padding: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel-head h3 { margin: 0; font-size: 15px; }
.user-log-panel { margin-top: 18px; }
.user-log-body { max-height: 320px; overflow: auto; }
.log-list { list-style: none; margin: 0; padding: 0; }
.log-list li { display: flex; align-items: center; gap: 10px; padding: 7px 2px; border-bottom: 1px solid var(--line, #eef0f4); font-size: 13px; }
.log-list li:last-child { border-bottom: none; }
.log-time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 132px; }
.log-actor { font-weight: 600; }
.log-target { color: var(--muted); }
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; margin-bottom: 16px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.toolbar .tb-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.toolbar input, .toolbar select {
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
  font-size: 13px; color: var(--text); outline: none; font-family: inherit;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }

/* ---------- Table ---------- */
.table-wrap { overflow: visible; width: max-content; min-width: 100%; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th, td { text-align: left; padding: 13px 14px; font-size: 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
tbody tr:hover { background: #fafbff; }
td .row-title { font-weight: 600; }
.cell-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { text-align: center; padding: 40px; color: var(--muted); }

/* ---------- Badge / tag ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 500; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.b-green { color: var(--ok); background: #e8f7ee; }
.b-gray { color: var(--muted); background: #f0f1f4; }
.b-blue { color: var(--info); background: #e8f0fe; }
.b-orange { color: var(--warn); background: #fdf0e0; }
.b-red { color: var(--danger); background: #fdeaea; }
.b-purple { color: var(--brand); background: var(--brand-soft); }
.b-teal { color: #0f6e56; background: #e1f5ee; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 6px; font-size: 12px; background: var(--brand-soft); color: var(--brand); }

/* ---------- Pagination ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }
.pager button { min-width: 38px; height: 38px; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; cursor: pointer; font-size: 15px; font-weight: 600; }
.pager button.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .5; cursor: not-allowed; }
.pager .info { color: var(--muted); font-size: 14px; }

/* ---------- Modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(20,22,30,.45); display: grid; place-items: center; z-index: 60; padding: 20px; }
.modal { width: 100%; max-width: 560px; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 微信转发卡片 ---------- */
.share-card { text-align: left; }
.share-card-img { width: 100%; max-width: 300px; display: block; margin: 0 auto 14px; border-radius: 18px; box-shadow: 0 10px 28px rgba(109,94,252,0.20); }
.share-title { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 8px; }
.share-desc { font-size: 14px; color: var(--muted); line-height: 1.6; margin-bottom: 14px; word-break: break-all; }
.share-qr { width: 180px; height: 180px; border-radius: 12px; border: 1px solid var(--line); margin: 0 auto 12px; display: block; }
.share-link { font-size: 12px; color: var(--brand); background: var(--brand-soft); border-radius: 8px; padding: 8px 10px; word-break: break-all; }
.share-link a { color: var(--brand); text-decoration: none; border-bottom: 1px solid currentColor; display: inline-block; max-width: 100%; word-break: break-all; }
.lnk { color: var(--primary); text-decoration: none; word-break: break-all; }
.lnk:hover { text-decoration: underline; }
/* ---------- 培训详情卡片 ---------- */
.detail-card { display: flex; flex-direction: column; gap: 2px; }
.detail-row { display: flex; align-items: flex-start; gap: 14px; padding: 11px 2px; border-bottom: 1px dashed var(--line); }
.detail-row:last-child { border-bottom: none; }
.detail-k { flex: 0 0 88px; color: var(--muted); font-size: 13px; padding-top: 1px; }
.detail-v { flex: 1; color: var(--text); font-size: 14px; line-height: 1.6; word-break: break-all; }
.close-x { border: none; background: transparent; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.pwd-meter { margin: -4px 0 12px; font-size: 12px; color: var(--muted); }
.pwd-meter::before { content: ''; display: block; height: 6px; border-radius: 4px; margin-bottom: 6px; background: var(--line); transition: background .2s, width .2s; }
.pwd-meter.lv-weak { color: var(--danger); }
.pwd-meter.lv-weak::before { width: 33%; background: var(--danger); }
.pwd-meter.lv-mid { color: var(--warn); }
.pwd-meter.lv-mid::before { width: 66%; background: var(--warn); }
.pwd-meter.lv-strong { color: var(--ok); }
.pwd-meter.lv-strong::before { width: 100%; background: var(--ok); }
textarea { resize: vertical; min-height: 74px; }

/* ---------- Chart ---------- */
.chart-box { width: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; }
.legend span { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 13px; }
.bar-row .bl { width: 68px; color: var(--muted); flex: none; }
.bar-track { flex: 1; height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }
.bar-row .bv { width: 34px; text-align: right; font-weight: 600; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.mini-list li:last-child { border-bottom: none; }
.mini-list .mt { color: var(--muted); font-size: 12px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 11px 20px; border-radius: 10px; font-size: 13px;
  box-shadow: var(--shadow-lg); z-index: 90; animation: toastIn .2s;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Responsive ---------- */
@media (max-width: 900px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } .grid-2, .grid-2b { grid-template-columns: 1fr; } }
@media (max-width: 720px) {
  .icon-btn { display: inline-flex; }
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); transition: transform .25s; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .form-grid { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .user-chip span:last-child { display: none; }
}
