/* ============================================================
   用户端大盘布局：侧边栏 + 顶栏 + 内容区
   ============================================================ */
.app { display: flex; min-height: 100vh; }

/* ---------- 侧边栏 ---------- */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 22px; font-size: 18px; font-weight: 800; letter-spacing: -0.3px;
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; background: var(--brand-grad);
  display: grid; place-items: center; color: #fff; font-size: 16px;
  box-shadow: 0 4px 12px rgba(255, 138, 0, 0.35);
}
.brand .logo svg { width: 18px; height: 18px; }
.nav { flex: 1; padding: 8px 12px; }
.nav-group { font-size: 11px; color: var(--muted); padding: 14px 12px 6px; letter-spacing: 0.5px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 14px; margin: 2px 0; border-radius: var(--r-sm);
  font-size: 14px; color: var(--text-2); cursor: pointer;
  transition: all var(--dur) var(--ease);
}
.nav-item .ic { width: 20px; height: 20px; color: var(--muted); flex-shrink: 0; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover .ic { color: var(--text-2); }
.nav-item.active { background: linear-gradient(90deg, rgba(255,138,0,0.12), rgba(255,138,0,0.02)); color: var(--brand); font-weight: 600; }
.nav-item.active .ic { color: var(--brand); }
.side-foot { padding: 16px 18px; border-top: 1px solid var(--line); }
.user-chip { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.user-chip .avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--brand-grad);
  display: grid; place-items: center; color: #fff; font-weight: 700;
}
.user-chip .uname { font-weight: 600; }
.logout { font-size: 12px; color: var(--muted); cursor: pointer; margin-top: 8px; display: inline-block; }
.logout:hover { color: var(--red); }

/* ---------- 主内容 ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 28px; gap: 16px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .title { font-size: 17px; font-weight: 700; }
.topbar .spacer { flex: 1; }
.content { padding: 26px 28px; overflow-y: auto; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; display: flex; align-items: center; gap: 10px; }
.page-head h1 .h-ic { width: 24px; height: 24px; color: var(--brand); flex-shrink: 0; }
.page-head .desc { font-size: 13px; color: var(--text-2); margin-top: 4px; }
/* 顶栏菜单按钮图标 */
.menu-toggle .ic { width: 18px; height: 18px; }

.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; flex-wrap: wrap; }

/* ---------- 国家选择器 ---------- */
.country-picker { position: relative; }
.country-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: var(--r-sm); font-size: 14px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  cursor: pointer; transition: all var(--dur) var(--ease);
}
.country-btn:hover { border-color: #d3dae6; box-shadow: var(--shadow-sm); }
.country-btn .caret { color: var(--muted); width: 14px; height: 14px; }
/* 国家代码徽章（替代 emoji 国旗） */
.flag-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 26px; height: 18px; padding: 0 5px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.3px; line-height: 1;
  color: var(--brand); background: #fff4e6; border-radius: 4px; flex-shrink: 0;
}
.country-menu {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 30;
  width: 200px; max-height: 340px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r);
  box-shadow: var(--shadow-lg); padding: 6px; animation: fadeUp 0.16s var(--ease) both;
}
.country-opt {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: var(--r-sm); font-size: 14px; cursor: pointer;
  transition: background var(--dur) var(--ease);
}
.country-opt:hover { background: var(--surface-2); }
.country-opt.active { background: #fff4e6; color: var(--brand); font-weight: 600; }
.country-opt.active .flag-badge { background: #ffe4c2; }
/* 国家下拉：搜索框 */
.country-search { padding: 6px 6px 8px; position: sticky; top: 0; background: var(--surface); }
.country-search input { width: 100%; padding: 8px 11px; font-size: 13px; }
.country-empty { padding: 18px; text-align: center; color: var(--muted); font-size: 13px; }
/* 刷新按钮加载态 */
.btn .btn-spin {
  width: 13px; height: 13px; border: 2px solid rgba(255,255,255,0.5);
  border-top-color: #fff; border-radius: 50%; display: inline-block;
  animation: spin 0.7s linear infinite;
}
.btn.loading { pointer-events: none; opacity: 0.85; }

/* ---------- 指标卡 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px; box-shadow: var(--shadow-sm); transition: box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card .label { font-size: 13px; color: var(--text-2); display: flex; align-items: center; gap: 7px; }
.stat-card .label .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 10px; letter-spacing: -0.5px; }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.stat-card .sub b { color: var(--green); font-weight: 600; }

/* ---------- 图表卡 ---------- */
.chart-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 22px; margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.chart-box h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; }
.chart { width: 100%; height: 360px; }
.chart-tall { height: 460px; }
.chart-sm { height: 300px; }
.chart-box h3 .sec-ic { margin-right: 6px; }
/* 两栏图表布局（达人大盘全球/地区数据） */
.chart-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.chart-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.chart-cell { min-width: 0; }
.cell-title { font-size: 13px; font-weight: 600; color: var(--muted, #5b667a); margin-bottom: 8px; }
/* 达人大盘分区标题 */
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 800; letter-spacing: -0.3px;
  margin: 6px 0 14px;
}
.section-title .s-ic { width: 18px; height: 18px; color: var(--brand); flex-shrink: 0; }
@media (max-width: 900px) {
  .chart-2col, .chart-cols { grid-template-columns: 1fr; gap: 16px; }
  .chart-tall { height: 400px; }
}

/* ---------- 榜单 ---------- */
.rank-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }

/* ---------- 国家大盘三栏布局 ---------- */
.board-grid {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
  margin-bottom: 22px;
}
.board-col { min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.board-col-left .rank-panel, .board-col-right .rank-panel { position: sticky; top: 84px; }
/* 榜单面板 Tab 头 */
.panel-tabs { display: flex; gap: 4px; padding: 14px 16px 0; border-bottom: 1px solid var(--line); }
.panel-tabs .tab {
  border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
  padding: 8px 10px 12px; border-bottom: 2px solid transparent;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
  display: inline-flex; align-items: center; gap: 6px;
}
.panel-tabs .tab .ti { width: 16px; height: 16px; flex-shrink: 0; }
.panel-tabs .tab:hover { color: var(--text); }
.panel-tabs .tab.active { color: var(--brand); border-bottom-color: var(--brand); }
/* 小号 Tab（用于图表卡右上角 商品/店铺 切换） */
.panel-tabs-sm { padding: 0; border-bottom: none; gap: 2px; }
.panel-tabs-sm .tab { font-size: 13px; padding: 4px 10px; border-bottom: none; border-radius: var(--r-sm); }
.panel-tabs-sm .tab.active { background: #fff4e6; }
/* 达人总览：紧凑指标卡（4 张一排） */
.stat-grid-sm { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.stat-grid-sm .stat-card { padding: 14px 16px; }
.stat-grid-sm .stat-card .value { font-size: 20px; margin-top: 6px; }
/* 图表卡标题行（标题 + 右侧切换） */
.box-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.box-head h3 { margin-bottom: 0; }
/* 分类竞争分析：占比指标网格 */
.metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.metric-item { padding: 14px 16px; border: 1px solid var(--line); border-radius: var(--r-lg); background: var(--surface-2); }
.metric-item .m-label { font-size: 12px; color: var(--text-2); }
.metric-item .m-value { font-size: 22px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; }
.metric-item .m-bar { height: 6px; border-radius: 3px; background: var(--line); margin-top: 10px; overflow: hidden; }
.metric-item .m-bar > span { display: block; height: 100%; background: var(--brand-grad); border-radius: 3px; }

.rank-panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm); overflow: hidden;
}
.rank-panel h3 { font-size: 15px; font-weight: 700; padding: 18px 20px 12px; }
.rank-item { display: flex; align-items: center; gap: 13px; padding: 10px 20px; transition: background var(--dur) var(--ease); }
.rank-item:hover { background: var(--surface-2); }
.rank-no { width: 24px; text-align: center; font-weight: 800; font-size: 14px; color: var(--muted); flex-shrink: 0; }
.rank-no.top { color: var(--brand); }
.rank-cover { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; background: var(--surface-2); flex-shrink: 0; border: 1px solid var(--line); }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.rank-val { font-size: 14px; font-weight: 700; color: var(--brand); text-align: right; flex-shrink: 0; }
.loading, .empty { padding: 36px; text-align: center; color: var(--muted); font-size: 13px; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 0 auto 10px; }

/* ---------- 响应式断点 ---------- */
@media (max-width: 1280px) {
  .board-grid { grid-template-columns: 280px minmax(0, 1fr); }
  .board-col-right { grid-column: 1 / -1; }
  .board-col-right .rank-panel { position: static; }
}
@media (max-width: 1024px) {
  .rank-cols { grid-template-columns: 1fr; }
  .board-grid { grid-template-columns: 1fr; }
  .board-col-left .rank-panel, .board-col-right .rank-panel { position: static; }
}
@media (max-width: 768px) {
  .sidebar { position: fixed; left: -232px; z-index: 50; transition: left var(--dur) var(--ease); box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .menu-toggle { display: inline-flex !important; }
  .content { padding: 18px 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
  .backdrop.show { display: block; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
}
.menu-toggle { display: none; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: var(--r-sm); border: 1px solid var(--line); background: var(--surface); cursor: pointer; font-size: 18px; }
.backdrop { display: none; position: fixed; inset: 0; background: rgba(16,24,40,0.4); z-index: 40; }
