/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary: #91CDEB;
  --primary-dark: #5ba8cc;
  --accent: #9C27B0;
  --sidebar-w: 280px;
  --header-h: 60px;
  --text-primary: #212121;
  --text-secondary: #555;
  --text-hint: #999;
  --bg: #F5F5F5;
  --bg-grey: #EEEEEE;
  --divider: #E0E0E0;
  --card-bg: #fff;
  --shadow: 0 2px 8px rgba(0,0,0,.1);
  --radius: 8px;
}

html, body {
  height: 100%;
  font-family: -apple-system, "PingFang SC", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
}

a { text-decoration: none; color: inherit; }

/* ===== 侧边栏 ===== */
#sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: #fff; z-index: 200;
  display: flex; flex-direction: column;
  box-shadow: 2px 0 16px rgba(0,0,0,.12);
  transform: translateX(-100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  overflow: hidden;
}
#sidebar.open { transform: translateX(0); }

.sidebar-header {
  background: linear-gradient(135deg, #91CDEB 0%, #5ba8cc 100%);
  padding: 28px 24px 20px;
  min-height: 115px;
  display: flex; flex-direction: column; justify-content: flex-end;
  flex-shrink: 0;
}
.sidebar-header h1 {
  color: #fff; font-size: 26px; font-weight: 700;
  letter-spacing: .05em; text-shadow: 0 2px 4px rgba(0,0,0,.15);
}
.sidebar-header p { color: rgba(255,255,255,.9); font-size: 13px; margin-top: 4px; }

.sidebar-body { flex: 1; overflow-y: auto; padding: 8px 0 16px; }

.nav-row { display: flex; gap: 8px; padding: 4px 20px; margin-bottom: 2px; }
.nav-item-half {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px; border-radius: var(--radius); cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  background: #f5f5f5; transition: background .15s;
}
.nav-item-half:hover, .nav-item-half.active { background: #e3f2fd; color: var(--primary-dark); }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; margin: 2px 20px;
  border-radius: var(--radius); cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--text-primary);
  transition: background .15s;
}
.nav-item:hover { background: #f0f8ff; }
.nav-item.active { background: #e3f2fd; color: var(--primary-dark); }
.nav-icon { font-size: 17px; }
.nav-divider { height: 1px; background: rgba(145,205,235,.25); margin: 10px 32px; }

/* ===== 遮罩 ===== */
#overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  z-index: 199; display: none;
}
#overlay.show { display: block; }

/* ===== 顶部栏 ===== */
#header {
  position: fixed; top: 0; left: 0; right: 0; height: var(--header-h);
  background: var(--primary); z-index: 100;
  display: flex; align-items: center; padding: 0 16px; gap: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
#btnMenu {
  font-size: 24px; color: #fff; cursor: pointer;
  width: 40px; text-align: center; flex-shrink: 0;
  background: none; border: none; padding: 0;
}
.header-title { flex: 1; }
.header-title h2 { color: #fff; font-size: 20px; font-weight: 700; }
.header-title small { color: rgba(255,255,255,.85); font-size: 10px; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.btn-header {
  background: rgba(255,255,255,.25); color: #fff; border: none;
  padding: 6px 12px; border-radius: 6px; font-size: 13px; cursor: pointer;
  transition: background .15s; white-space: nowrap;
}
.btn-header:hover { background: rgba(255,255,255,.4); }
.btn-header.active { background: rgba(255,255,255,.5); }

/* ===== 搜索栏 ===== */
#searchBar {
  position: fixed; top: var(--header-h); left: 0; right: 0; z-index: 99;
  background: #fff; padding: 8px 12px;
  box-shadow: 0 2px 4px rgba(0,0,0,.07);
  display: flex; align-items: center; gap: 8px;
}
#etSearch {
  flex: 1; padding: 9px 12px 9px 36px;
  border: 1.5px solid #ddd; border-radius: 20px;
  font-size: 14px; outline: none; background: #f8f8f8;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 10px center;
  transition: border-color .2s;
}
#etSearch:focus { border-color: var(--primary); background-color: #fff; }

/* ===== 筛选条 ===== */
#filterBar {
  position: fixed; top: calc(var(--header-h) + 52px); left: 0; right: 0; z-index: 98;
  background: #fff; padding: 6px 12px;
  display: flex; gap: 6px; flex-wrap: nowrap; overflow-x: auto;
  border-bottom: 1px solid var(--divider);
  scrollbar-width: none;
}
#filterBar::-webkit-scrollbar { display: none; }
.filter-chip {
  padding: 4px 12px; border-radius: 16px; font-size: 12px; cursor: pointer;
  border: 1.5px solid var(--divider); background: #fff; color: var(--text-secondary);
  transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.filter-chip:hover { border-color: var(--primary); color: var(--primary-dark); }
.filter-chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ===== 主内容 ===== */
#main {
  margin-top: calc(var(--header-h) + 52px + 44px);
  padding: 8px;
}

/* ===== 成员网格 ===== */
#memberGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: 8px;
}
#memberGrid.two-col { grid-template-columns: repeat(2, 1fr); }
#memberGrid.one-col { grid-template-columns: 1fr; }

/* ===== 成员卡片 ===== */
.member-card {
  background: var(--card-bg); border-radius: var(--radius);
  box-shadow: var(--shadow); overflow: hidden; position: relative;
  transition: transform .15s, box-shadow .15s; display: block;
}
.member-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.14); }
.card-inner { display: flex; align-items: center; padding: 10px 12px; gap: 12px; }
.avatar-wrap {
  width: 40px; height: 47px; flex-shrink: 0;
  border-radius: 4px; overflow: hidden; background: #e0e0e0;
}
.avatar-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; }
.avatar-placeholder {
  width: 100%; height: 100%; background: #ddd;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #bbb;
}
.card-info { flex: 1; min-width: 0; }
.card-name {
  font-size: 14px; font-weight: 700; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-gen { font-size: 11px; color: var(--text-hint); margin-top: 3px; line-height: 1.4; }
.card-divider { height: 1px; background: #eee; }

/* 角标 */
.card-badges { position: absolute; top: 0; left: 0; display: flex; }
.badge-tag {
  font-size: 8px; font-weight: 700; color: #fff;
  padding: 2px 6px;
}
.tag-active  { background: #4CAF50; }
.tag-paused  { background: #FF9800; }
.tag-history { background: #9e9e9e; }
.tag-grad    { background: #9C27B0; }
.remark-tag {
  position: absolute; bottom: 0; right: 0;
  font-size: 8px; font-weight: 700; color: #fff;
  background: #666; padding: 2px 6px;
}

/* ===== 子页面通用工具栏 ===== */
.sub-toolbar {
  background: var(--primary); color: #fff;
  padding: 0 16px; height: 56px;
  display: flex; align-items: center; gap: 12px;
  position: sticky; top: 0; z-index: 10;
}
.sub-toolbar.accent { background: var(--accent); }
.sub-toolbar.red    { background: #F44336; }
.sub-toolbar.orange { background: #FF9800; }
.sub-toolbar.blue   { background: #1565C0; }
.sub-toolbar.gold   { background: #FFC107; color: #333; }
.back-btn { font-size: 22px; cursor: pointer; text-decoration: none; color: inherit; }
.sub-toolbar h2 { font-size: 18px; font-weight: 700; flex: 1; }

/* ===== 成员详情页 ===== */
.detail-hero {
  background: var(--bg-grey); padding: 20px;
  display: flex; gap: 20px; align-items: flex-start;
}
.detail-avatar {
  width: 90px; height: 120px; border-radius: 4px;
  overflow: hidden; background: #ddd; flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.detail-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.detail-hero-info { flex: 1; }
.d-name { font-size: 26px; font-weight: 700; color: var(--text-primary); }
.d-group { font-size: 15px; color: var(--text-secondary); margin-top: 8px; }
.d-gen   { font-size: 13px; color: var(--text-hint); margin-top: 4px; }
.d-tags  { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.d-tag   { font-size: 11px; color: #fff; padding: 2px 8px; border-radius: 10px; }

.detail-section { padding: 16px; border-bottom: 1px solid var(--divider); }
.section-title {
  display: flex; align-items: center; gap: 8px;
  font-size: 16px; font-weight: 700; color: var(--text-primary);
  margin-bottom: 10px;
}
.section-title::before {
  content: ''; display: block; width: 4px; height: 16px;
  background: var(--accent); border-radius: 2px; flex-shrink: 0;
}
.detail-section p { font-size: 15px; color: var(--text-secondary); line-height: 1.8; }
.info-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.info-table td { padding: 5px 0; vertical-align: top; }
.info-table td:first-child { color: var(--text-hint); width: 90px; flex-shrink: 0; }

/* 经历列表 */
.exp-list { list-style: none; }
.exp-list li {
  padding: 5px 0 5px 16px; position: relative;
  font-size: 14px; color: var(--text-secondary); line-height: 1.6;
  border-bottom: 1px solid #f5f5f5;
}
.exp-list li::before {
  content: ''; position: absolute; left: 0; top: 12px;
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}

/* 队服照 */
.photo-tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.photo-tab {
  padding: 5px 14px; font-size: 13px; cursor: pointer; border-radius: 4px;
  background: var(--divider); color: var(--text-secondary); border: none;
}
.photo-tab.active { background: var(--accent); color: #fff; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 8px; }
.photo-grid img {
  width: 100%; aspect-ratio: 3/4; object-fit: cover;
  border-radius: 4px; cursor: pointer; display: block;
}

/* 总决选表格 */
.election-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.election-table th {
  background: #f5f5f5; padding: 7px 8px; text-align: left;
  font-weight: 700; color: var(--text-hint); font-size: 12px;
}
.election-table td { padding: 7px 8px; border-bottom: 1px solid #f0f0f0; }
.election-table tr:last-child td { border-bottom: none; }
.votes-cell { color: var(--primary-dark); font-weight: 700; text-align: right; }

/* 收藏按钮 */
.fav-btn {
  background: rgba(255,255,255,.25); color: #fff; border: none;
  padding: 6px 14px; border-radius: 6px; font-size: 13px; cursor: pointer;
  transition: background .15s;
}
.fav-btn:hover { background: rgba(255,255,255,.4); }
.fav-btn.active { background: #FFC107; color: #333; }

/* ===== 总决选页 ===== */
.round-tabs {
  background: #fff; padding: 10px 12px;
  display: flex; gap: 6px; flex-wrap: wrap;
  border-bottom: 1px solid var(--divider);
  position: sticky; top: 56px; z-index: 5;
}
.round-tab {
  padding: 5px 12px; border-radius: 16px; font-size: 12px; cursor: pointer;
  border: 1.5px solid var(--divider); background: #fff; color: var(--text-secondary);
  transition: all .15s; text-decoration: none;
}
.round-tab:hover { border-color: var(--primary); }
.round-tab.active { background: #1a237e; border-color: #1a237e; color: #fff; }

.election-list { padding: 8px; }
.election-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; background: #fff; border-radius: var(--radius);
  margin-bottom: 6px; box-shadow: var(--shadow);
}
.rank-num { font-size: 20px; font-weight: 900; color: var(--text-hint); width: 36px; text-align: center; flex-shrink: 0; }
.rank-num.r1 { color: #FFD700; }
.rank-num.r2 { color: #C0C0C0; }
.rank-num.r3 { color: #CD7F32; }
.e-name { font-size: 15px; font-weight: 700; }
.e-team { font-size: 12px; color: var(--text-hint); margin-top: 2px; }
.e-votes { font-size: 13px; color: var(--primary-dark); font-weight: 700; white-space: nowrap; }

/* ===== 时间线 ===== */
.timeline-list { padding: 16px; }
.tl-item { display: flex; gap: 16px; margin-bottom: 20px; }
.tl-dot-col { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.tl-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--primary); margin-top: 4px; }
.tl-line { flex: 1; width: 2px; background: var(--divider); margin-top: 4px; min-height: 20px; }
.tl-content { flex: 1; padding-bottom: 8px; }
.tl-date  { font-size: 12px; color: var(--text-hint); margin-bottom: 3px; }
.tl-title { font-size: 15px; font-weight: 700; margin-bottom: 4px; }
.tl-members { font-size: 13px; color: var(--text-secondary); line-height: 1.7; }

/* ===== 离团时间线 ===== */
.leave-list { padding: 8px; }
.leave-item {
  background: #fff; border-radius: var(--radius); padding: 12px 16px;
  margin-bottom: 8px; box-shadow: var(--shadow);
  border-left: 4px solid #F44336; display: block;
}
.leave-item:hover { background: #fff8f8; }
.leave-date { font-size: 12px; color: var(--text-hint); }
.leave-name { font-size: 15px; font-weight: 700; margin-top: 2px; }
.leave-team { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.leave-reason { font-size: 12px; color: #F44336; margin-top: 4px; }

/* ===== 生日时间线 ===== */
.birthday-month {
  font-size: 18px; font-weight: 700; color: var(--primary-dark);
  padding: 12px 16px 4px; background: var(--bg);
  position: sticky; top: 56px; z-index: 4;
}
.birthday-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: #fff;
  border-bottom: 1px solid var(--divider); cursor: pointer;
}
.birthday-item:hover { background: #f9f9f9; }
.bday-badge {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; flex-shrink: 0;
}
.b-name { font-size: 15px; font-weight: 700; }
.b-team { font-size: 12px; color: var(--text-hint); margin-top: 2px; }

/* ===== 全球48系 ===== */
.g48-group-header {
  background: linear-gradient(135deg, #1565C0, #1976D2);
  color: #fff; padding: 10px 16px; font-size: 15px; font-weight: 700;
}
.g48-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: #fff;
  border-bottom: 1px solid var(--divider);
}
.g48-name { font-size: 14px; font-weight: 700; flex: 1; }
.g48-team { font-size: 12px; color: var(--text-hint); }

/* ===== 收藏页 ===== */
.fav-empty {
  text-align: center; padding: 60px 20px;
  color: var(--text-hint); font-size: 15px; line-height: 2;
}

/* ===== 灯箱 ===== */
#lightbox {
  position: fixed; inset: 0; background: rgba(0,0,0,.92);
  z-index: 500; display: none; align-items: center; justify-content: center;
}
#lightbox.open { display: flex; }
#lightbox img { max-width: 92vw; max-height: 92vh; object-fit: contain; border-radius: 4px; }
.lb-close {
  position: absolute; top: 16px; right: 20px;
  color: #fff; font-size: 32px; cursor: pointer; line-height: 1;
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-hint); font-size: 15px;
}

/* ===== 响应式 ===== */
@media (min-width: 768px) {
  #memberGrid { grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); }
}
@media (min-width: 1024px) {
#sidebar { transform: translateX(0); }
#overlay { display: none !important; }
#header, #searchBar, #filterBar, #main, .main-navbar { left: var(--sidebar-w); }
#btnMenu { display: none; }
.sidebar-close-btn { display: none; }
.nav-icon-btn.menu-btn { display: none; }
.page-content {
  margin-left: var(--sidebar-w);
}
.timeline-list {
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
  padding: 24px 32px;
}
}

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #aaa; }