/* =================== 基础 =================== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  font-family: 'Inter', 'PingFang SC', 'Noto Sans SC', 'Microsoft YaHei', -apple-system, sans-serif;
  background: #F9F9FB;
  color: #0F1419;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', 'Menlo', monospace; }

/* =================== 登录页 =================== */
.login-page {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #F4F2FF 0%, #F9F9FB 50%, #ECFDF5 100%);
}
.login-bg {
  position: absolute; inset: 0; z-index: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(80,70,229,0.12) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(16,185,129,0.10) 0%, transparent 40%);
}
.login-card {
  position: relative; z-index: 1;
  width: 380px; max-width: 92%;
  background: #FFFFFF;
  border-radius: 16px;
  padding: 36px 32px 28px;
  box-shadow: 0 10px 40px rgba(15,20,25,0.10), 0 2px 6px rgba(15,20,25,0.04);
}
.login-logo { display: flex; align-items: center; justify-content: center; margin-bottom: 28px; }
.login-logo .brand-logo { height: 52px; width: auto; object-fit: contain; }
.login-title { font-size: 18px; font-weight: 600; color: #0F1419; }
.login-subtitle { font-size: 12px; color: #9CA3AF; }
.login-form { display: flex; flex-direction: column; gap: 14px; }
.login-form label { display: flex; flex-direction: column; gap: 6px; }
.login-form label > span { font-size: 12px; color: #6B7280; font-weight: 500; }
.login-form input {
  height: 40px; padding: 0 12px;
  border: 1px solid #E7E7EA; border-radius: 8px;
  background: #FFFFFF; font-size: 14px; color: #0F1419;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.login-form input:focus { border-color: #5046E5; box-shadow: 0 0 0 3px rgba(80,70,229,0.10); }
.login-error { color: #DC2626; font-size: 12px; min-height: 16px; }
.login-submit {
  height: 42px; border: none; border-radius: 8px;
  background: #5046E5; color: #FFFFFF; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background .15s;
}
.login-submit:hover { background: #3F36D1; }
.login-submit:disabled { opacity: .6; cursor: not-allowed; }
.login-hint { margin-top: 18px; padding: 12px; border-radius: 8px; background: #F9F9FB; color: #6B7280; font-size: 12px; }

/* =================== App Shell =================== */
.app-shell { display: flex; height: 100vh; }

/* 侧边栏 */
.sidebar {
  width: 232px; flex-shrink: 0;
  background: #FFFFFF;
  border-right: 1px solid #F1F2F4;
  display: flex; flex-direction: column;
  padding: 0;
}
.logo-row { display: flex; align-items: center; padding: 18px; height: 64px; }
.logo-row .brand-logo { height: 36px; width: auto; object-fit: contain; }
.logo-mark { width: 28px; height: 28px; }
.logo-text { display: flex; flex-direction: column; gap: 1px; }
.logo-app { font-size: 14px; font-weight: 600; color: #0F1419; }
.logo-sub { font-size: 10px; color: #9CA3AF; }
.nav-group { padding: 12px; display: flex; flex-direction: column; gap: 2px; }
.nav-group-label { font-size: 11px; color: #9CA3AF; font-weight: 500; padding: 6px 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px; border-radius: 8px;
  font-size: 14px; color: #4B5563; cursor: pointer;
  transition: background .12s, color .12s;
}
.nav-item:hover { background: #F9F9FB; }
.nav-item.active { background: #EEEDFE; color: #5046E5; }
.nav-item svg { flex-shrink: 0; }
.sidebar-spacer { flex: 1; }
.user-block {
  display: flex; align-items: center; gap: 10px;
  padding: 16px; border-top: 1px solid #F1F2F4;
}
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: #5046E5; color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600;
}
.user-text { display: flex; flex-direction: column; gap: 1px; }
.user-name { font-size: 13px; font-weight: 500; color: #0F1419; }
.user-role { font-size: 11px; color: #9CA3AF; }

/* 主体 */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.header {
  height: 64px; padding: 14px;
  display: flex; align-items: center; gap: 12px;
  background: #FFFFFF; border-bottom: 1px solid #F1F2F4;
}
.search-box {
  display: flex; align-items: center; gap: 8px;
  width: 320px; height: 36px; padding: 0 10px;
  background: #F9F9FB; border-radius: 8px;
}
.search-box input { flex: 1; border: none; background: transparent; outline: none; font-size: 13px; color: #0F1419; }
.search-box input::placeholder { color: #9CA3AF; }
.header-spacer { flex: 1; }
.sync-chip {
  display: flex; align-items: center; gap: 8px;
  height: 32px; padding: 0 12px; border-radius: 100px;
  background: #ECFDF5; font-size: 12px; color: #059669; font-weight: 500;
}
.sync-chip.warn { background: #FEF3C7; color: #B45309; }
.sync-chip.err { background: #FEF2F2; color: #DC2626; }
.sync-chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.icon-btn {
  width: 36px; height: 36px; border: none; border-radius: 8px;
  background: #F9F9FB; color: #6B7280;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .12s;
}
.icon-btn:hover { background: #F1F2F4; }

/* 内容区 */
.content { flex: 1; overflow: auto; padding: 24px; }

/* =================== 通用 =================== */
.page-header {
  display: flex; align-items: center; gap: 12px; margin-bottom: 16px;
}
.page-header-text { display: flex; flex-direction: column; gap: 3px; }
.page-title { font-size: 22px; font-weight: 600; color: #0F1419; }
.page-subtitle { font-size: 12px; color: #6B7280; }
.page-spacer { flex: 1; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 14px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
  background: #FFFFFF; color: #0F1419; border-color: #E7E7EA;
}
.btn:hover { background: #F9F9FB; }
.btn-primary { background: #5046E5; color: #FFFFFF; border-color: #5046E5; }
.btn-primary:hover { background: #3F36D1; }
.btn-danger { background: #FFFFFF; color: #DC2626; border-color: #FCA5A5; }
.btn-danger:hover { background: #FEF2F2; }
.btn-ghost { background: transparent; border-color: transparent; color: #5046E5; }
.btn-ghost:hover { background: #EEEDFE; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

.card {
  background: #FFFFFF; border-radius: 12px; padding: 20px;
  box-shadow: 0 1px 2px rgba(15,20,25,0.04), 0 4px 12px rgba(15,20,25,0.06);
}

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }
.kpi-card { display: flex; flex-direction: column; gap: 10px; }
.kpi-label { font-size: 13px; color: #6B7280; }
.kpi-value { font-size: 30px; font-weight: 600; color: #0F1419; line-height: 1.2; }
.kpi-delta { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.kpi-delta-up { color: #059669; display: flex; align-items: center; gap: 4px; background: #ECFDF5; padding: 4px 8px; border-radius: 100px; }
.kpi-delta-down { color: #DC2626; display: flex; align-items: center; gap: 4px; background: #FEF2F2; padding: 4px 8px; border-radius: 100px; }
.kpi-delta-sub { color: #9CA3AF; }

.row-2 { display: grid; grid-template-columns: 1fr 380px; gap: 16px; }
.row-2-eq { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.card-title { font-size: 15px; font-weight: 600; color: #0F1419; }
.card-subtitle { font-size: 12px; color: #6B7280; margin-top: 4px; }
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.card-header .spacer { flex: 1; }

/* 表格 */
.tbl-wrap { background: #FFFFFF; border-radius: 12px; overflow: hidden; box-shadow: 0 1px 2px rgba(15,20,25,0.04), 0 4px 12px rgba(15,20,25,0.06); }
.tbl-head, .tbl-row {
  display: grid; align-items: center;
  padding: 12px 20px; gap: 12px; font-size: 13px;
}
.tbl-head { background: #F9F9FB; color: #6B7280; font-weight: 500; font-size: 12px; height: 48px; }
.tbl-row { border-top: 1px solid #F1F2F4; height: 64px; }
.tbl-row:hover { background: #FAFAFC; }
.tbl-cell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tbl-cell.member { display: flex; align-items: center; gap: 10px; }
.tbl-cell .avatar { width: 32px; height: 32px; border-radius: 50%; background: #5046E5; color: #FFF; display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.tbl-cell .stack { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tbl-cell .stack .name { font-size: 13px; font-weight: 500; color: #0F1419; }
.tbl-cell .stack .sub { font-size: 11px; color: #9CA3AF; }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 100px;
  font-size: 11px; font-weight: 500;
}
.pill-retail { background: #E0F2FE; color: #0369A1; }
.pill-b2b { background: #EEEDFE; color: #5046E5; }
.pill-active { background: #ECFDF5; color: #059669; }
.pill-active .d { width: 6px; height: 6px; border-radius: 50%; background: #10B981; }
.pill-frozen { background: #FEF3C7; color: #B45309; }
.pill-level { background: transparent; padding: 0; font-weight: 500; }
.pill-level.silver { color: #9CA3AF; }
.pill-level.gold { color: #B45309; }
.pill-level.platinum { color: #5046E5; }
.pill-level.partner { color: #5046E5; }
.pill-level.bronze { color: #6B7280; }

.tbl-actions { display: flex; gap: 6px; }

/* 分页 */
.pager {
  display: flex; align-items: center; gap: 8px;
  padding: 18px; font-size: 12px; color: #6B7280;
}
.pager .spacer { flex: 1; }
.pager-btn {
  min-width: 32px; height: 32px; padding: 0 14px;
  border: 1px solid #E7E7EA; border-radius: 8px;
  background: #FFFFFF; color: #0F1419; font-size: 12px;
  cursor: pointer; transition: background .12s;
  display: inline-flex; align-items: center; justify-content: center;
}
.pager-btn:hover { background: #F9F9FB; }
.pager-btn.active { background: #5046E5; color: #FFFFFF; border-color: #5046E5; }

/* 筛选条 */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  background: #FFFFFF; padding: 14px; border-radius: 12px;
  box-shadow: 0 1px 2px rgba(15,20,25,0.04), 0 4px 12px rgba(15,20,25,0.06);
  margin-bottom: 16px;
}
.filter-input, .filter-select {
  height: 36px; padding: 0 12px; border-radius: 8px;
  background: #F9F9FB; border: 1px solid transparent;
  font-size: 13px; color: #0F1419; outline: none;
}
.filter-input:focus, .filter-select:focus { border-color: #5046E5; background: #FFFFFF; }
.filter-select { background: #FFFFFF; border-color: #E7E7EA; cursor: pointer; }

/* 弹窗 */
.modal-root {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15,20,25,0.40);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow: auto;
}
.modal {
  background: #FFFFFF; border-radius: 16px;
  width: 480px; max-width: 100%;
  max-height: calc(100vh - 48px); overflow: auto;
  box-shadow: 0 20px 50px rgba(15,20,25,0.20);
}
.modal.wide { width: 720px; }
.modal-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 24px; border-bottom: 1px solid #F1F2F4;
}
.modal-title { font-size: 16px; font-weight: 600; color: #0F1419; flex: 1; }
.modal-close {
  width: 28px; height: 28px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; color: #6B7280;
  display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: #F1F2F4; }
.modal-body { padding: 20px 24px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #F1F2F4; display: flex; justify-content: flex-end; gap: 8px; }
.modal-form-row { display: flex; flex-direction: column; gap: 6px; }
.modal-form-row.col2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-form-row label > span { font-size: 12px; color: #6B7280; font-weight: 500; }
.modal-form-row input, .modal-form-row select, .modal-form-row textarea {
  height: 38px; padding: 0 12px; border-radius: 8px;
  border: 1px solid #E7E7EA; background: #FFFFFF;
  font-size: 13px; color: #0F1419; outline: none;
  transition: border-color .12s, box-shadow .12s;
}
.modal-form-row textarea { height: auto; min-height: 72px; padding: 10px 12px; font-family: inherit; resize: vertical; }
.modal-form-row input:focus, .modal-form-row select:focus, .modal-form-row textarea:focus {
  border-color: #5046E5; box-shadow: 0 0 0 3px rgba(80,70,229,0.10);
}
.modal-form-error { color: #DC2626; font-size: 12px; }

/* 开关 */
.switch { width: 36px; height: 20px; border-radius: 10px; background: #E7E7EA; position: relative; cursor: pointer; transition: background .12s; flex-shrink: 0; }
.switch.on { background: #10B981; }
.switch-knob { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #FFFFFF; transition: transform .12s; box-shadow: 0 1px 2px rgba(0,0,0,0.2); }
.switch.on .switch-knob { transform: translateX(16px); }

/* Toast */
.toast-host { position: fixed; top: 24px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  background: #0F1419; color: #FFFFFF;
  padding: 10px 14px; border-radius: 8px;
  font-size: 13px; min-width: 200px; max-width: 360px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.20);
  pointer-events: auto;
  animation: toastIn .2s ease-out;
}
.toast.success { background: #059669; }
.toast.error { background: #DC2626; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }

/* 趋势图 */
.trend-svg { width: 100%; height: 180px; }

/* 进度条 */
.progress { width: 100%; height: 6px; background: #F1F2F4; border-radius: 3px; overflow: hidden; }
.progress-bar { height: 100%; background: #5046E5; border-radius: 3px; }

/* KV 行 */
.kv-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; font-size: 12px; }
.kv-row .k { color: #6B7280; min-width: 120px; }
.kv-row .v { color: #0F1419; font-weight: 500; margin-left: auto; text-align: right; }
.kv-row .spacer { flex: 1; }

/* 配置区块 */
.section { display: flex; flex-direction: column; gap: 14px; }
.section + .section { margin-top: 16px; }

/* 会员详情卡 */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.detail-row { display: flex; flex-direction: column; gap: 4px; padding: 12px; background: #F9F9FB; border-radius: 8px; }
.detail-row .k { font-size: 12px; color: #6B7280; }
.detail-row .v { font-size: 14px; color: #0F1419; font-weight: 500; }

/* 响应 */
@media (max-width: 1100px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .row-2 { grid-template-columns: 1fr; }
  .row-2-eq { grid-template-columns: 1fr; }
  .sidebar { width: 200px; }
}
