:root {
  --bg: #f5f5f2;
  --surface: #ffffff;
  --surface-2: #fafaf7;
  --surface-3: #f2f2ee;
  --line: #e6e5df;
  --line-strong: #d5d4cc;
  --ink: #1a1a18;
  --ink-2: #55544e;
  --ink-3: #8b8a82;
  --brand: #ff2442;
  --brand-2: #e01f3d;
  --brand-soft: #ffeef0;
  --up: #b8342a;
  --up-soft: #fbeae8;
  --down: #1a7a58;
  --down-soft: #e6f2ec;
  --warn: #96650c;
  --warn-soft: #fbf2df;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(26, 26, 24, 0.05);
  --shadow-md: 0 8px 24px rgba(26, 26, 24, 0.09);
  --shadow-lg: 0 24px 60px rgba(26, 26, 24, 0.16);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  font-size: 13px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.tnum { font-variant-numeric: tabular-nums; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.login-aside {
  background: #38090f;
  color: #f7dfe2;
  padding: 56px 56px 40px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-aside::after {
  content: "";
  position: absolute;
  right: -160px;
  bottom: -220px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  border: 1px solid rgba(255, 220, 224, 0.14);
  box-shadow: 0 0 0 60px rgba(255, 220, 224, 0.05), 0 0 0 140px rgba(255, 220, 224, 0.035);
}
.login-aside h1 { font-size: 30px; line-height: 1.35; margin: 0 0 16px; font-weight: 500; letter-spacing: -0.02em; }
.login-aside p { color: #e0aeb4; font-size: 13px; max-width: 380px; margin: 0; }
.login-points { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; }
.login-points li { display: flex; gap: 10px; font-size: 13px; color: #eec8cd; }
.login-points b { display: block; color: #fdeef0; font-weight: 500; margin-bottom: 1px; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: #ff6b7f; margin-top: 8px; flex: none; }
.login-brand { display: flex; align-items: center; gap: 10px; font-size: 14px; color: #fdeef0; }
.login-foot { font-size: 12px; color: #b3767e; }

.login-main { display: flex; align-items: center; justify-content: center; padding: 40px; background: var(--surface); }
.login-card { width: 100%; max-width: 352px; }
.login-card h2 { font-size: 20px; margin: 0 0 6px; font-weight: 500; }
.login-card .sub { color: var(--ink-3); margin: 0 0 26px; font-size: 13px; }
.seg { display: flex; background: var(--surface-3); border-radius: 9px; padding: 3px; margin-bottom: 20px; }
.seg button {
  flex: 1; border: 0; background: transparent; padding: 7px 0; border-radius: 7px;
  color: var(--ink-2); font-size: 13px; transition: all .15s;
}
.seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 500; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 6px; }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line-strong); background: var(--surface);
  border-radius: 8px; padding: 9px 11px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px var(--brand-soft); }
.textarea { min-height: 108px; resize: vertical; line-height: 1.6; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; transition: all .15s; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-3); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-block { width: 100%; padding: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-3); border-color: transparent; }
.form-error {
  background: var(--up-soft); color: var(--up); border-radius: 8px;
  padding: 9px 11px; font-size: 12px; margin-bottom: 14px;
}
.login-hint { margin-top: 18px; padding: 12px 14px; background: var(--surface-2); border: 1px dashed var(--line-strong); border-radius: 9px; font-size: 12px; color: var(--ink-2); line-height: 1.8; }
.login-hint code { background: var(--surface-3); padding: 1px 5px; border-radius: 4px; color: var(--ink); font-size: 12px; }

/* ---------- 应用骨架 ---------- */
.app { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 18px 14px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; }
.brand .mark {
  width: 32px; height: 32px; border-radius: 9px; background: var(--brand);
  display: grid; place-items: center; flex: none;
}
.brand .name { font-size: 14px; font-weight: 500; letter-spacing: -0.01em; }
.brand .sub { font-size: 11px; color: var(--ink-3); margin-top: -2px; }
.nav { display: grid; gap: 2px; }
.nav-label { font-size: 11px; color: var(--ink-3); padding: 0 10px 6px; letter-spacing: .04em; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  color: var(--ink-2); text-decoration: none; transition: all .12s;
}
.nav a:hover { background: var(--surface-3); text-decoration: none; color: var(--ink); }
.nav a.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav a.active svg { stroke: var(--brand); }
.nav svg { stroke: var(--ink-3); flex: none; }
.nav .count { margin-left: auto; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 8px; border-radius: 8px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-size: 12px; font-weight: 500; flex: none; }
.user-chip .meta { min-width: 0; }
.user-chip .n { font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .r { font-size: 11px; color: var(--ink-3); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; border-bottom: 1px solid var(--line); background: rgba(255,255,255,.86);
  backdrop-filter: blur(8px); display: flex; align-items: center; gap: 14px;
  padding: 0 26px; position: sticky; top: 0; z-index: 30;
}
.topbar h1 { font-size: 15px; font-weight: 500; margin: 0; }
.topbar .crumb { color: var(--ink-3); font-size: 12px; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.content { padding: 20px 26px 48px; max-width: 1480px; width: 100%; }

.banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 9px 14px; margin-bottom: 18px; font-size: 12px; color: var(--ink-2);
}
.banner .spacer { margin-left: auto; }
.banner b { font-weight: 500; color: var(--ink); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 20px; font-size: 11.5px; background: var(--surface-3); color: var(--ink-2); white-space: nowrap; }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.err { background: #f7e5e3; color: #a8322a; }
.pill.dim { background: var(--surface-3); color: var(--ink-3); }
.pill.up { background: var(--up-soft); color: var(--up); }
.pill.ok { background: var(--down-soft); color: var(--down); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }

/* ---------- 卡片 / 统计 ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 13.5px; font-weight: 500; margin: 0; }
.card-head .desc { font-size: 11.5px; color: var(--ink-3); }
.card-head .right { margin-left: auto; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 15px 16px; }
.stat .k { font-size: 11.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.stat .v { font-size: 25px; font-weight: 500; letter-spacing: -0.02em; margin-top: 6px; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .f { font-size: 11.5px; color: var(--ink-3); margin-top: 4px; }
.stat .v small { font-size: 12px; color: var(--ink-3); font-weight: 400; margin-left: 3px; }
.bar { height: 4px; background: var(--surface-3); border-radius: 3px; margin: 9px 0 6px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--brand); border-radius: 3px; transition: width .3s; }
.bar.warn > span { background: var(--up); }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

.mini-list { padding: 4px 0 8px; }
.mini-row { display: flex; align-items: center; gap: 10px; padding: 9px 16px; }
.mini-row:hover { background: var(--surface-2); }
.rank { width: 18px; font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; text-align: center; flex: none; }
.rank.top { color: var(--brand); font-weight: 500; }
.mini-main { min-width: 0; flex: 1; }
.mini-title { font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-sub { font-size: 11px; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-num { text-align: right; flex: none; }
.mini-num .n { font-size: 13px; font-weight: 500; font-variant-numeric: tabular-nums; }
.mini-num .s { font-size: 11px; color: var(--ink-3); }

/* ---------- 工具条 ---------- */
.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs { display: inline-flex; background: var(--surface-3); border-radius: 9px; padding: 3px; gap: 2px; }
.tabs button { border: 0; background: transparent; padding: 6px 12px; border-radius: 7px; color: var(--ink-2); font-size: 12.5px; transition: all .13s; white-space: nowrap; }
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow-sm); }
/* 低粉高销子菜单（近期动销 / 历史累计）：独立一行放在主工具栏下方，带前缀标签表明从属关系 */
.lf-row { display: flex; align-items: center; gap: 10px; margin: -2px 0 8px; }
.lf-label { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.lf-row .tabs.lf-tabs { margin-left: 0; }
.tabs.lf-tabs button { padding: 5px 12px; font-size: 11.5px; }
.search { position: relative; }
.search input { padding-left: 30px; width: 220px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); stroke: var(--ink-3); }
.toolbar .grow { flex: 1; }

.note-line { font-size: 11.5px; color: var(--ink-3); margin: -6px 0 12px; display: flex; align-items: center; gap: 6px; }
.note-line b { color: var(--ink-2); font-weight: 400; }
/* 账号管理：功能分配复选框 */
.check-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; cursor: pointer; user-select: none; }
.check-chip input { accent-color: var(--brand-2); margin: 0; }

/* ---------- 表格 ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 920px; }
table.data thead th {
  text-align: left; font-weight: 400; font-size: 11.5px; color: var(--ink-3);
  padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  white-space: nowrap; position: sticky; top: 0; z-index: 1;
}
table.data thead th.sortable { cursor: pointer; user-select: none; }
table.data thead th.sortable:hover { color: var(--ink); background: var(--surface-3); }
table.data thead th .arrow { opacity: .45; margin-left: 3px; }
table.data thead th.num, table.data tbody td.num { text-align: right; }
table.data tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data tbody tr:hover td { background: var(--surface-2); }
table.data tbody td.num { font-variant-numeric: tabular-nums; }

.cell-item { display: flex; align-items: center; gap: 10px; min-width: 260px; }
.thumb {
  width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center;
  font-size: 11px; font-weight: 500; color: #fff; flex: none; letter-spacing: .02em;
}
.cover-img {
  width: 42px; height: 56px; border-radius: 7px; object-fit: cover; flex: none;
  background: var(--surface-3); border: 1px solid var(--line); display: block;
}
/* 店铺头像：方形圆角（小红书店铺头像位），商品仍是竖版主图 */
.cover-img.shop { width: 42px; height: 42px; border-radius: 50%; }
.cell-item .t { min-width: 0; }
.cell-item .t .title { font-size: 12.5px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.cell-item .t .shop { font-size: 11px; color: var(--ink-3); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: flex; align-items: center; gap: 8px; }
.xhs-link { color: var(--brand-2); font-size: 11px; white-space: nowrap; flex: none; }
.xhs-link:hover { text-decoration: underline; }
.cell-item .t .title a { color: inherit; }
.cell-item .t .title a:hover { color: var(--brand-2); }

.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--surface-3); color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.growth { font-weight: 500; font-variant-numeric: tabular-nums; }
.growth.up { color: var(--up); }
.growth.down { color: var(--down); }
.growth.none { color: var(--ink-3); font-weight: 400; }
.sub-note { display: block; font-size: 10.5px; color: var(--ink-3); font-weight: 400; margin-top: 1px; line-height: 1.35; max-width: 168px; margin-left: auto; }
.ratio { font-variant-numeric: tabular-nums; }
.ratio.hot { color: var(--up); font-weight: 500; }
.time-cell { font-size: 11.5px; color: var(--ink-2); white-space: nowrap; }
.row-act { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn {
  width: 26px; height: 26px; border-radius: 6px; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; color: var(--ink-3);
}
.icon-btn:hover { background: var(--surface-3); color: var(--ink); }
.icon-btn.on { color: var(--up); }
.icon-btn.danger:hover { background: #f7e5e3; color: #a8322a; }
.icon-btn svg { width: 15px; height: 15px; }

.empty { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.empty .big { font-size: 13px; color: var(--ink-2); margin-bottom: 4px; }
.empty .hint { font-size: 12px; }

.pager { display: flex; align-items: center; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--ink-2); }
.pager .spacer { flex: 1; }
.pager .pages { display: flex; gap: 4px; }
.pager button {
  min-width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink-2); font-size: 12px;
}
.pager button:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }
.pager button[aria-current="true"] { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- 抽屉 ---------- */
.scrim { position: fixed; inset: 0; background: rgba(20, 22, 20, .34); z-index: 60; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 560px; max-width: 94vw; background: var(--surface);
  z-index: 61; box-shadow: var(--shadow-lg); display: flex; flex-direction: column;
  animation: slide .22s cubic-bezier(.2,.8,.3,1);
}
@keyframes slide { from { transform: translateX(32px); opacity: .4 } to { transform: none; opacity: 1 } }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; gap: 12px; align-items: flex-start; }
.drawer-head h3 { font-size: 14px; margin: 0 0 3px; font-weight: 500; line-height: 1.45; }
.drawer-head .sub { font-size: 11.5px; color: var(--ink-3); }
.drawer-body { padding: 18px 20px 32px; overflow: auto; flex: 1; }
.close-x { margin-left: auto; width: 28px; height: 28px; border-radius: 7px; border: 0; background: var(--surface-3); display: grid; place-items: center; flex: none; }

.metric-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.metric { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; }
.metric .k { font-size: 11px; color: var(--ink-3); }
.metric .v { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; margin-top: 2px; }
.metric .v small { font-size: 11px; color: var(--ink-3); font-weight: 400; }

.section-title { font-size: 12px; color: var(--ink-3); margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
.reason-box { background: var(--warn-soft); border: 1px solid #f0e0bd; color: #6f4c08; border-radius: 9px; padding: 10px 12px; font-size: 12px; line-height: 1.65; }
.reason-box b { font-weight: 500; }

.chart-box { background: var(--surface-2); border: 1px solid var(--line); border-radius: 9px; padding: 12px 10px 6px; }
.chart-box svg { display: block; width: 100%; height: auto; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink-3); padding: 4px 6px 0; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-swatch { width: 10px; height: 2px; border-radius: 2px; }

table.mini { width: 100%; border-collapse: collapse; font-size: 12px; }
table.mini th { text-align: left; font-weight: 400; color: var(--ink-3); font-size: 11px; padding: 7px 8px; border-bottom: 1px solid var(--line); }
table.mini td { padding: 7px 8px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
table.mini tr:last-child td { border-bottom: 0; }

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 480px; max-width: 94vw;
  background: var(--surface); border-radius: var(--radius-lg); z-index: 61; box-shadow: var(--shadow-lg);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translate(-50%, -46%) scale(.98); opacity: 0 } to { transform: translate(-50%, -50%) scale(1); opacity: 1 } }
.modal-head { padding: 16px 18px 10px; }
.modal-head h3 { font-size: 14px; margin: 0 0 3px; font-weight: 500; }
.modal-head .sub { font-size: 11.5px; color: var(--ink-3); }
.modal-body { padding: 0 18px 6px; }
.modal-foot { padding: 14px 18px; display: flex; gap: 8px; align-items: center; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }
.quota-chip { font-size: 11.5px; color: var(--ink-2); background: var(--surface-3); padding: 4px 9px; border-radius: 20px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #1f211f; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 12.5px;
  z-index: 90; box-shadow: var(--shadow-md); max-width: 520px; line-height: 1.5;
}
.toast.err { background: #7d2a22; }

.skeleton { height: 12px; border-radius: 6px; background: linear-gradient(90deg, var(--surface-3) 25%, #ecebe5 37%, var(--surface-3) 63%); background-size: 400% 100%; animation: sk 1.2s ease infinite; }
@keyframes sk { 0% { background-position: 100% 50% } 100% { background-position: 0 50% } }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .three-col, .two-col { grid-template-columns: 1fr; }
  .login-wrap { grid-template-columns: 1fr; }
  .login-aside { display: none; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  .sidebar-foot { margin: 0; border: 0; padding: 0; }
  .nav { display: flex; }
  .content { padding: 16px; }
}

/* hidden 属性优先于任何 display 设置（如 .lf-row 的 flex） */
[hidden] { display: none !important; }
