:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e4e8ef;
  --line-2: #eef1f6;
  --text: #111827;
  --text-2: #4b5563;
  --muted: #8b93a1;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #eef4ff;
  --green: #16a34a;
  --green-soft: #eafaf0;
  --red: #dc2626;
  --red-soft: #fdeeee;
  --amber: #d97706;
  --amber-soft: #fff7e8;
  --purple: #7c3aed;
  --side: #0f172a;
  --side-2: #16213a;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -12px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

/* ---------------- 登录 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
}
.login-brand {
  background: radial-gradient(1200px 600px at 20% 0%, #1e3a8a 0%, #0f172a 55%, #0b1120 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  right: -160px; bottom: -180px;
  background: radial-gradient(circle, rgba(37, 99, 235, .45), transparent 65%);
  border-radius: 50%;
}
.login-brand h1 { font-size: 30px; line-height: 1.35; margin: 0 0 14px; letter-spacing: .5px; }
.login-brand p { color: #9fb0cd; line-height: 1.9; margin: 0; font-size: 14px; }
.login-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 40px; }
.login-logo .mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; font-weight: 700; font-size: 18px;
  box-shadow: 0 8px 20px -8px rgba(59, 130, 246, .9);
}
.login-points { position: relative; z-index: 1; margin-top: 30px; }
.login-points div { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; color: #c7d5ea; font-size: 13.5px; }
.login-points span.dot { width: 6px; height: 6px; border-radius: 50%; background: #3b82f6; margin-top: 7px; flex: none; }
.login-foot { color: #64748b; font-size: 12px; position: relative; z-index: 1; }

.login-form-side { display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-card { width: 100%; max-width: 380px; }
.login-card h2 { margin: 0 0 6px; font-size: 22px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; font-size: 13px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; font-weight: 500; }
.input, .select, .textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
.textarea { min-height: 78px; resize: vertical; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text-2);
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
  font-weight: 500;
}
.btn:hover { border-color: #cfd6e2; background: #fafbfd; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); }
.btn-danger { color: var(--red); border-color: #f3c9c9; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f1f4f9; }
.btn-block { width: 100%; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.demo-accounts { margin-top: 24px; border-top: 1px dashed var(--line); padding-top: 16px; }
.demo-accounts .t { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.demo-accounts .grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.demo-chip {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 9px;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  text-align: left;
  line-height: 1.5;
}
.demo-chip:hover { border-color: var(--primary); background: var(--primary-soft); }
.demo-chip b { display: block; color: var(--text); font-size: 12.5px; }
.demo-chip span { color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; }

/* ---------------- 布局 ---------------- */
.layout { display: grid; grid-template-columns: 218px 1fr; min-height: 100vh; }
.side {
  background: var(--side);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.side-head { padding: 20px 18px 16px; display: flex; align-items: center; gap: 10px; }
.side-head .mark {
  width: 32px; height: 32px; border-radius: 8px; flex: none;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 14px;
}
.side-head .tt { font-size: 13.5px; font-weight: 600; color: #fff; line-height: 1.3; }
.side-head .tt small { display: block; font-weight: 400; color: #7c8aa5; font-size: 11px; margin-top: 2px; }
.nav { padding: 8px 10px; flex: 1; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  color: #a9b6c9;
  font-size: 13.5px;
  margin-bottom: 2px;
  transition: all .14s;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.on { background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(37, 99, 235, .72)); color: #fff; }
.nav-item .ic { width: 16px; text-align: center; opacity: .9; font-size: 13px; }
.nav-group { font-size: 11px; color: #5b6779; padding: 14px 11px 6px; letter-spacing: .6px; }
.side-foot { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07); font-size: 12px; color: #64748b; }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .left { display: flex; align-items: center; gap: 14px; }
.topbar h3 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .crumb { color: var(--muted); font-size: 12px; }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #2563eb);
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.userbox { display: flex; align-items: center; gap: 9px; }
.userbox .n { font-size: 13px; font-weight: 500; line-height: 1.2; }
.userbox .r { font-size: 11px; color: var(--muted); }
.content { padding: 22px 24px 40px; max-width: 1500px; width: 100%; }

/* ---------------- 通用 ---------------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0 0 4px; font-size: 19px; }
.page-head .desc { color: var(--muted); font-size: 12.5px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.card-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-2);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.card-head h4 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .lb { font-size: 12px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 5px; }
.kpi .vl { font-size: 25px; font-weight: 650; letter-spacing: -.5px; line-height: 1.1; }
.kpi .vl small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 2px; }
.kpi .sub { font-size: 11.5px; color: var(--muted); margin-top: 7px; }
.kpi.warn { border-color: #f6d8a8; background: linear-gradient(180deg, #fffdf7, #fff); }
.kpi.warn .vl { color: var(--amber); }
.kpi.good .vl { color: var(--green); }
.kpi.bad .vl { color: var(--red); }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11.5px; font-weight: 500; line-height: 1.7;
  background: #f1f4f9; color: var(--text-2);
  white-space: nowrap;
}
.badge.blue { background: var(--primary-soft); color: var(--primary-2); }
.badge.green { background: var(--green-soft); color: #15803d; }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.amber { background: var(--amber-soft); color: #b45309; }
.badge.purple { background: #f3edff; color: #6d28d9; }
.badge.gray { background: #f1f4f9; color: #64748b; }

.table-wrap { overflow-x: auto; }
table.tb { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tb th {
  text-align: left; padding: 11px 14px; color: var(--muted);
  font-weight: 500; font-size: 12px; background: #fafbfd;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.tb td { padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.tb tr:hover td { background: #fafcff; }
table.tb tr:last-child td { border-bottom: none; }
table.tb .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; color: var(--text-2); }
table.tb .acts { display: flex; gap: 6px; flex-wrap: wrap; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); font-size: 13px; }
.empty .ic { font-size: 26px; display: block; margin-bottom: 8px; opacity: .35; }

.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.filters .input, .filters .select { width: auto; min-width: 150px; padding: 7px 10px; }
.filters .spacer { flex: 1; }

.pager { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line-2); color: var(--muted); font-size: 12.5px; }
.pager .spacer { flex: 1; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
@media (max-width: 1180px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* 表单 */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.form-grid .full { grid-column: 1 / -1; }
.req::after { content: " *"; color: var(--red); }

/* 标签选择 */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 5px 11px; border-radius: 20px; border: 1px solid var(--line);
  background: #fff; cursor: pointer; font-size: 12.5px; color: var(--text-2);
  transition: all .14s; user-select: none;
}
.chip:hover { border-color: #c7d2e4; }
.chip.on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.on.red { background: var(--red); border-color: var(--red); }
.chip.on.green { background: var(--green); border-color: var(--green); }

/* 提示 */
.alert { padding: 12px 14px; border-radius: 10px; font-size: 13px; line-height: 1.7; margin-bottom: 14px; display: flex; gap: 10px; }
.alert .ic { flex: none; }
.alert.info { background: var(--primary-soft); color: #1e40af; border: 1px solid #d7e4ff; }
.alert.warn { background: var(--amber-soft); color: #92400e; border: 1px solid #f7dfb4; }
.alert.ok { background: var(--green-soft); color: #166534; border: 1px solid #cdeed9; }
.alert.err { background: var(--red-soft); color: #991b1b; border: 1px solid #f6d0d0; }

/* 图表 */
.bars { display: flex; align-items: flex-end; gap: 10px; height: 132px; padding: 6px 2px 0; }
.bars .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .bar { width: 100%; max-width: 46px; background: linear-gradient(180deg, #60a5fa, #2563eb); border-radius: 5px 5px 0 0; position: relative; min-height: 3px; transition: height .3s; }
.bars .bar .in { position: absolute; bottom: 0; left: 0; right: 0; background: #dc2626; border-radius: 0; opacity: .85; }
.bars .lb { font-size: 11px; color: var(--muted); }
.bars .vl { font-size: 11px; color: var(--text-2); font-weight: 600; }

.funnel { display: flex; flex-direction: column; gap: 8px; }
.funnel .row { display: flex; align-items: center; gap: 10px; }
.funnel .nm { width: 74px; font-size: 12.5px; color: var(--text-2); flex: none; }
.funnel .track { flex: 1; height: 26px; background: #f3f5f9; border-radius: 6px; overflow: hidden; position: relative; }
.funnel .fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #6366f1); border-radius: 6px; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px; color: #fff; font-size: 11.5px; font-weight: 600; min-width: 34px; transition: width .3s; }
.funnel .rate { width: 54px; text-align: right; font-size: 12px; color: var(--muted); flex: none; }

.rank-list .r { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--line-2); font-size: 13px; }
.rank-list .r:last-child { border-bottom: none; }
.rank-list .idx { width: 18px; height: 18px; border-radius: 5px; background: #f1f4f9; color: var(--muted); display: grid; place-items: center; font-size: 11px; flex: none; font-weight: 600; }
.rank-list .r:nth-child(1) .idx { background: var(--primary); color: #fff; }
.rank-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-list .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.rank-list .s { font-size: 11.5px; color: var(--muted); width: 76px; text-align: right; flex: none; }

/* 模态框 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 20px 40px; z-index: 100; overflow-y: auto;
  backdrop-filter: blur(2px);
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  box-shadow: 0 24px 60px -12px rgba(15, 23, 42, .35);
  animation: pop .18s ease-out;
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 20px 12px; font-size: 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
.modal-head .x { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; padding: 0 4px; }
.modal-body { padding: 0 20px 6px; max-height: 62vh; overflow-y: auto; }
.modal-foot { padding: 14px 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }

/* toast */
#toast-box { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  padding: 9px 16px; border-radius: 9px; font-size: 13px; color: #fff;
  background: #1f2937; box-shadow: 0 10px 30px -8px rgba(0, 0, 0, .4);
  animation: slide .2s ease-out; max-width: 520px;
}
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }
.toast.warn { background: #b45309; }
@keyframes slide { from { transform: translateY(-10px); opacity: 0; } to { transform: none; opacity: 1; } }

/* 商家品牌头 */
.brand-hero {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 22px; border-radius: var(--radius);
  background: linear-gradient(120deg, #0f172a, #1e3a8a);
  color: #fff; margin-bottom: 16px; position: relative; overflow: hidden;
}
.brand-hero::after { content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: radial-gradient(circle, rgba(59, 130, 246, .5), transparent 70%); }
.brand-hero .logo {
  width: 62px; height: 62px; border-radius: 14px; background: rgba(255, 255, 255, .12);
  display: grid; place-items: center; font-size: 22px; font-weight: 700; flex: none;
  border: 1px solid rgba(255, 255, 255, .18); overflow: hidden;
}
.brand-hero .logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-hero .tt { font-size: 19px; font-weight: 600; margin-bottom: 5px; }
.brand-hero .st { font-size: 12.5px; color: #a8c0e0; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 18px; }
.tab { padding: 12px 14px; font-size: 13.5px; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

.stat-inline { display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.stat-inline b { color: var(--text); font-weight: 600; }

.hl { background: #fffbe6; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb0 { margin-bottom: 0; }
.row-flex { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
