/* ============================================
   比赛组队系统 - 简洁风格样式表
   ============================================ */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: #f4f6fb;
  color: #1f2937;
  font-size: 15px;
  line-height: 1.6;
}
a { color: #4f46e5; text-decoration: none; }
a:hover { color: #4338ca; }
img { max-width: 100%; }
.muted { color: #6b7280; }
.small { font-size: 13px; }

.container { max-width: 1120px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  position: sticky; top: 0; z-index: 50;
}
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: #111827; font-size: 17px; }
.brand:hover { color: #111827; }
.brand-logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff; font-size: 15px; font-weight: 700;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  position: relative;
  padding: 7px 12px; border-radius: 8px;
  color: #4b5563; font-size: 15px;
}
.nav a:hover { background: #eef2ff; color: #4338ca; }
.nav a.active { background: #eef2ff; color: #4f46e5; font-weight: 600; }
.nav-dot {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px;
  background: #ef4444; color: #fff; border-radius: 999px; font-size: 12px;
}
.top-user { display: flex; align-items: center; gap: 10px; }
.top-nick { font-weight: 600; }
.lang-switch { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: #9ca3af; }
.lang-switch a { color: #9ca3af; padding: 2px 4px; border-radius: 5px; }
.lang-switch a:hover { color: #4f46e5; }
.lang-switch a.active { color: #4f46e5; font-weight: 700; background: #eef2ff; }
.lang-sep { color: #d1d5db; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid transparent; border-radius: 8px;
  padding: 8px 16px; font-size: 14px; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  text-decoration: none; line-height: 1.4;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: #4f46e5; color: #fff; }
.btn-primary:hover { background: #4338ca; color: #fff; }
.btn-outline { background: #fff; border-color: #d1d5db; color: #374151; }
.btn-outline:hover { border-color: #4f46e5; color: #4f46e5; }
.btn-ghost { background: transparent; color: #4b5563; }
.btn-ghost:hover { background: #f3f4f6; color: #111827; }
.btn-success { background: #16a34a; color: #fff; }
.btn-success:hover { background: #15803d; color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: #dc2626; }
.btn-danger:hover { background: #dc2626; border-color: #dc2626; color: #fff; }
.btn-danger-solid { background: #dc2626; color: #fff; }
.btn-danger-solid:hover { background: #b91c1c; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 7px; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.form-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 28px;
}
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 14px; color: #374151; }
.form-group label .req { color: #ef4444; }
.form-control {
  width: 100%; padding: 9px 12px; font-size: 14px;
  border: 1px solid #d1d5db; border-radius: 8px; background: #fff; color: #111827;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: #6366f1; box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }
textarea.form-control { resize: vertical; min-height: 96px; }
select.form-control { appearance: auto; }
.form-help { font-size: 12px; color: #9ca3af; margin-top: 4px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; }
.inline-form { display: inline; }

/* ---------- 提示 / 徽章 ---------- */
.alert {
  padding: 11px 16px; border-radius: 10px; margin-bottom: 18px; font-size: 14px;
  border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-danger  { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #b45309; }
.alert-info    { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger  { background: #fee2e2; color: #b91c1c; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-muted   { background: #f3f4f6; color: #6b7280; }

/* ---------- 头像 ---------- */
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 46px; height: 46px; border-radius: 50%;
  color: #fff; font-weight: 600; font-size: 19px; flex: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
}
.avatar-xs { width: 26px; height: 26px; font-size: 12px; }
.avatar-lg { width: 72px; height: 72px; font-size: 28px; }

/* ---------- 首页 Hero ---------- */
.hero {
  text-align: center; padding: 56px 0 40px;
}
.hero h1 { font-size: 32px; margin: 0 0 12px; letter-spacing: .5px; }
.hero p { color: #6b7280; font-size: 16px; margin: 0 0 22px; }
.hero-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- 区块标题 ---------- */
.section { margin: 34px 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-title { font-size: 20px; margin: 0; font-weight: 700; }
.section-sub { color: #6b7280; font-size: 13px; }

/* ---------- 名片网格 ---------- */
.pcard-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 16px;
}
.pcard, .tcard {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px;
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
  transition: box-shadow .15s, transform .15s;
}
.pcard:hover, .tcard:hover { box-shadow: 0 8px 24px rgba(31, 41, 55, .08); transform: translateY(-2px); }
.pcard-head { display: flex; align-items: center; gap: 12px; }
.pcard-name { margin: 0; font-size: 16px; }
.pcard-id { min-width: 0; }
.pcard-meta { color: #6b7280; font-size: 13px; }
.pcard-pref { font-size: 13px; }
.pref-label {
  display: inline-block; margin-right: 6px; padding: 2px 8px;
  background: #eef2ff; color: #4f46e5; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.pcard-bio { color: #4b5563; font-size: 13px; margin: 0; }
.pcard-foot { margin-top: auto; display: flex; justify-content: flex-end; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  padding: 2px 9px; border-radius: 6px; background: #f3f4f6;
  color: #374151; font-size: 12px;
}
.empty {
  text-align: center; color: #9ca3af; background: #fff; border: 1px dashed #d1d5db;
  border-radius: 14px; padding: 40px 20px;
}

/* ---------- 队伍卡片 ---------- */
.tcard-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tcard-name { margin: 0; font-size: 17px; }
.tcard-desc { color: #4b5563; font-size: 13px; margin: 0; }
.tcard-meta { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #4b5563; }
.tcard-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; }

/* ---------- 详情页 / 通用卡片 ---------- */
.panel {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 22px;
  margin-bottom: 18px;
}
.panel h2 { margin: 0 0 14px; font-size: 17px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 24px; }
.detail-item { padding: 10px 0; border-bottom: 1px dashed #eef0f4; }
.detail-item:last-child { border-bottom: 0; }
.detail-label { color: #9ca3af; font-size: 13px; margin-bottom: 2px; }
.detail-value { color: #1f2937; }

.team-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.team-head h1 { margin: 0 0 6px; font-size: 24px; }
.team-leader { display: flex; align-items: center; gap: 8px; color: #4b5563; font-size: 14px; }

.member-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
}
.member-row:last-child { border-bottom: 0; }
.member-name { font-weight: 600; }
.member-role-tag {
  font-size: 12px; padding: 1px 8px; border-radius: 6px;
  background: #eef2ff; color: #4f46e5; font-weight: 600;
}
.member-actions { margin-left: auto; }

/* ---------- 邀请列表 ---------- */
.invite-item {
  display: flex; align-items: center; gap: 14px; padding: 14px 0;
  border-bottom: 1px solid #f3f4f6; flex-wrap: wrap;
}
.invite-item:last-child { border-bottom: 0; }
.invite-main { flex: 1; min-width: 220px; }
.invite-title { font-weight: 600; }

/* ---------- 表格 ---------- */
.table-wrap { background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 11px 14px; text-align: left; border-bottom: 1px solid #f0f1f5; white-space: nowrap; }
.table th { background: #fafbfe; color: #6b7280; font-weight: 600; font-size: 13px; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { display: flex; gap: 8px; align-items: center; }

/* ---------- 认证页 ---------- */
.auth-wrap { max-width: 420px; margin: 60px auto; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head h1 { font-size: 24px; margin: 0 0 6px; }
.auth-head p { color: #6b7280; margin: 0; }
.auth-alt { text-align: center; margin-top: 16px; color: #6b7280; font-size: 14px; }

/* ---------- 后台布局 ---------- */
.admin-body { display: flex; min-height: 100vh; background: #f4f6fb; }
.sidebar {
  width: 220px; flex: none; background: #111827; color: #d1d5db;
  display: flex; flex-direction: column; padding: 18px 12px; position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 8px; color: #fff;
  font-weight: 700; font-size: 16px; padding: 4px 8px 18px;
}
.sidebar-brand:hover { color: #fff; }
.side-nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.side-nav a {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-radius: 8px; color: #d1d5db; font-size: 14px;
}
.side-nav a:hover { background: #1f2937; color: #fff; }
.side-nav a.active { background: #4f46e5; color: #fff; font-weight: 600; }
.side-count {
  font-size: 12px; background: #374151; color: #d1d5db; border-radius: 999px; padding: 0 8px;
}
.side-count.warn { background: #ef4444; color: #fff; }
.sidebar-foot { border-top: 1px solid #1f2937; padding-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.sidebar-foot a { color: #9ca3af; font-size: 13px; padding: 4px 8px; border-radius: 6px; }
.sidebar-foot a:hover { color: #fff; background: #1f2937; }
.admin-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-top {
  background: #fff; border-bottom: 1px solid #e5e7eb;
  padding: 16px 26px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 40;
}
.admin-title { margin: 0; font-size: 20px; }
.admin-user { display: flex; align-items: center; gap: 8px; color: #374151; font-weight: 500; }
.admin-main { padding: 24px 26px; flex: 1; }
.admin-footer { padding: 16px 26px; text-align: right; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px; padding: 18px 20px;
}
.stat-num { font-size: 30px; font-weight: 800; color: #111827; }
.stat-label { color: #6b7280; font-size: 13px; }
.stat-card.accent { background: linear-gradient(135deg, #4f46e5, #7c3aed); border: 0; }
.stat-card.accent .stat-num, .stat-card.accent .stat-label { color: #fff; }

.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.tab-link {
  padding: 7px 14px; border-radius: 999px; background: #fff; border: 1px solid #e5e7eb;
  color: #4b5563; font-size: 14px;
}
.tab-link.active { background: #4f46e5; border-color: #4f46e5; color: #fff; font-weight: 600; }

/* ---------- 页脚 ---------- */
.footer { margin-top: 48px; padding: 22px 0; border-top: 1px solid #e5e7eb; background: #fff; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; color: #6b7280; font-size: 13px; }

.hidden { display: none !important; }

/* ---------- 响应式 ---------- */
@media (max-width: 760px) {
  .topbar-inner { flex-wrap: wrap; height: auto; padding: 10px 0; gap: 10px; }
  .nav { order: 3; width: 100%; overflow-x: auto; }
  .form-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .admin-body { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; }
  .hero h1 { font-size: 25px; }
}

/* ==========================================================
   优化 & 移动端适配（v2）
   ========================================================== */
html { -webkit-text-size-adjust: 100%; }
body { -webkit-font-smoothing: antialiased; overflow-wrap: break-word; }
::selection { background: rgba(99, 102, 241, .18); }

.btn:active { transform: scale(.98); }
a:focus-visible, button:focus-visible, .form-control:focus-visible, select:focus-visible {
  outline: 2px solid rgba(99, 102, 241, .55);
  outline-offset: 1px;
}

/* 表格容器移动端内边距 */
.table-wrap { -webkit-overflow-scrolling: touch; }

/* ---------- 平板 / 小屏后台 ---------- */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .admin-top { padding: 14px 18px; }
  .admin-main { padding: 18px; }
}

@media (max-width: 860px) {
  .admin-body { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    padding: 8px 12px; display: block;
  }
  .sidebar-brand { padding: 4px 6px 8px; font-size: 15px; }
  .side-nav { flex-direction: row; overflow-x: auto; gap: 4px; padding-bottom: 2px; -webkit-overflow-scrolling: touch; }
  .side-nav a { white-space: nowrap; padding: 8px 10px; }
  .side-nav a .side-count { margin-left: 6px; }
  .sidebar-foot { flex-direction: row; align-items: center; gap: 14px; padding-top: 6px; margin-top: 6px; }
  .admin-top { position: sticky; top: 0; }
  .admin-user { flex-wrap: wrap; justify-content: flex-end; }
  .stat-grid { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
  .admin-main { padding: 14px 14px 20px; }
}

/* ---------- 手机端 ---------- */
@media (max-width: 760px) {
  .container { padding: 0 14px; }

  /* 顶栏：两行布局，导航可横向滑动 */
  .topbar-inner {
    display: grid; grid-template-columns: minmax(0, 1fr) auto;
    align-items: center; gap: 2px 10px; padding: 8px 0;
    height: auto;
  }
  .brand { font-size: 15px; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .brand-logo { width: 26px; height: 26px; font-size: 14px; flex: none; }
  .nav {
    grid-column: 1 / -1; order: 5;
    width: 100%; overflow-x: auto; gap: 2px;
    padding: 2px 0 4px; -webkit-overflow-scrolling: touch; scrollbar-width: none;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { white-space: nowrap; font-size: 14px; padding: 6px 10px; }
  .top-user { justify-content: flex-end; gap: 6px; flex-wrap: nowrap; }
  .top-nick { display: none; }
  .top-user .btn { padding: 6px 10px; font-size: 13px; min-height: 32px; }
  .top-user .avatar-xs { display: none; }
  .lang-switch { font-size: 12px; }

  /* 防止 iOS 聚焦自动放大 */
  .form-control, input, select, textarea { font-size: 16px; }

  /* 页面间距 */
  .page { padding-top: 4px; }
  .hero { padding: 26px 0 22px; }
  .hero h1 { font-size: clamp(23px, 6.5vw, 30px); line-height: 1.35; margin-bottom: 10px; }
  .hero p { font-size: 14.5px; margin-bottom: 16px; }
  .hero-actions .btn { min-height: 38px; }
  .section { margin: 24px 0; }
  .section-head { flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
  .section-title { font-size: 18px; }
  .footer { margin-top: 30px; padding: 16px 0; }
  .footer-inner { flex-direction: column; align-items: center; gap: 4px; text-align: center; }

  /* 认证卡片 */
  .auth-wrap { margin: 24px auto; }
  .form-card { padding: 18px 16px; border-radius: 12px; }
  .auth-head h1 { font-size: 21px; }
  .form-actions { flex-direction: column; }
  .form-actions .btn { width: 100%; }
  .project-fields .form-grid { grid-template-columns: 1fr; }

  /* 卡片 */
  .pcard-grid { grid-template-columns: 1fr; gap: 12px; }
  .pcard, .tcard { padding: 14px; }
  .pcard-name { font-size: 15px; }
  .panel { padding: 16px; border-radius: 12px; }
  .panel h2 { font-size: 16px; }
  .detail-label, .detail-value { font-size: 13.5px; }
  .empty { padding: 28px 16px; }

  /* 队伍详情 */
  .team-head { flex-direction: column; align-items: flex-start; }
  .team-head h1 { font-size: 21px; }
  .team-leader { align-self: stretch; }
  .member-row { flex-wrap: wrap; gap: 6px 10px; }
  .member-actions { margin-left: 0; width: 100%; }
  .member-actions .btn { width: auto; }

  /* 邀请 / 搜索结果 */
  .invite-item { flex-direction: column; align-items: flex-start; gap: 8px; }
  .invite-item .invite-main { width: 100%; }
  .invite-item form,
  .invite-item form.inline-form { width: 100%; display: flex; gap: 8px; flex-wrap: wrap; }
  .invite-item input.form-control,
  .invite-item textarea.form-control { width: 100% !important; max-width: 100%; }

  /* 输入框/选择框防溢出 */
  .panel input.form-control,
  .panel select.form-control { max-width: 100%; }
  .panel .form-control { max-width: 100%; }
  form .form-control { width: 100%; }

  /* 筛选/搜索栏 */
  .filter-bar form { flex: 1 1 100%; min-width: 0; }
  .filter-bar form .form-control { flex: 1; width: auto !important; min-width: 0; }
  .tab-link { padding: 6px 11px; font-size: 13px; }

  /* 表格 */
  table.table { font-size: 13px; }
  .table th, .table td { padding: 9px 8px; }
  .table .actions { flex-wrap: wrap; }
  .table .actions .btn { white-space: nowrap; }

  /* 后台统计 */
  .stat-card { padding: 13px 14px; border-radius: 12px; }
  .stat-num { font-size: 24px; }
  .stat-label { font-size: 12px; }
}

/* 超小屏（<=400） */
@media (max-width: 400px) {
  .top-user .btn:not(.btn-primary) { padding: 6px 8px; }
  .top-user .lang-switch a { padding: 2px 3px; }
  .brand span:last-child { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
}
