/* ================= 基础 ================= */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #eef2ff;
  --accent: #8b5cf6;
  --bg: #f4f5fb;
  --card: #ffffff;
  --text: #1e2235;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #e8eaf2;
  --danger: #ef4444;
  --ok: #10b981;
  --warn: #f59e0b;
  --radius: 16px;
  --grad: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --shadow: 0 1px 2px rgba(30, 34, 53, .04), 0 4px 14px rgba(30, 34, 53, .06);
  --shadow-lg: 0 12px 40px rgba(30, 34, 53, .18);
  --shadow-primary: 0 6px 18px rgba(99, 102, 241, .35);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(600px 300px at 100% -50px, rgba(139, 92, 246, .08), transparent),
    radial-gradient(500px 260px at -80px 120px, rgba(99, 102, 241, .07), transparent),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.5;
}

button { font-family: inherit; cursor: pointer; }
input { font-family: inherit; }
a { text-decoration: none; color: inherit; }

body.sheet-open { overflow: hidden; }

::selection { background: rgba(99, 102, 241, .2); }

/* 细滚动条 */
*::-webkit-scrollbar { width: 6px; height: 6px; }
*::-webkit-scrollbar-thumb { background: rgba(107, 114, 128, .3); border-radius: 6px; }
*::-webkit-scrollbar-track { background: transparent; }

/* ================= 页面骨架 ================= */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px 0;
  min-height: 100vh;
  animation: pageIn .3s ease;
}
@keyframes pageIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.page-pad { height: calc(76px + env(safe-area-inset-bottom)); }

.page-head { padding: 10px 4px 14px; }
.page-head h1 {
  margin: 0; font-size: 24px; font-weight: 800; letter-spacing: .3px;
  background: var(--grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }
.page-note {
  color: var(--text-2); font-size: 12px;
  padding: 0 4px; margin: 12px 0;
}

/* ================= 底部导航 ================= */
.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: flex;
  justify-content: space-around;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -4px 20px rgba(30, 34, 53, .06);
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar .tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--text-3);
  padding: 4px 0;
  transition: color .2s;
}
.tabbar .tab svg {
  width: 22px; height: 22px;
  transition: transform .2s;
}
.tabbar .tab.active { color: var(--primary); font-weight: 700; }
.tabbar .tab.active svg {
  transform: translateY(-1px) scale(1.08);
  filter: drop-shadow(0 2px 5px rgba(99, 102, 241, .45));
}

/* ================= 卡片与通用 ================= */
.card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(232, 234, 242, .8);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
  transition: box-shadow .2s, transform .2s;
}
.card-title-bar {
  font-weight: 700; font-size: 15px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.card-title-bar::before {
  content: "";
  width: 4px; height: 16px;
  border-radius: 4px;
  background: var(--grad);
}
.empty {
  text-align: center; color: var(--text-3);
  padding: 48px 16px; font-size: 14px; line-height: 2;
}
.muted { color: var(--text-2); }
.muted-text { color: var(--text-2); font-size: 12px; }
.ok-text { color: var(--ok); font-size: 12px; }
.warn-text { color: var(--warn); font-size: 12px; }
.small { font-size: 12px; }
.mini-pad { padding: 6px 0 2px; font-size: 13px; }

/* ================= 按钮 ================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  transition: all .18s;
}
.btn:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.btn:active { transform: scale(.97); box-shadow: none; }
.btn.primary {
  background: var(--grad);
  border: none;
  color: #fff;
  box-shadow: var(--shadow-primary);
}
.btn.primary:hover { box-shadow: 0 8px 24px rgba(99, 102, 241, .45); filter: brightness(1.05); }
.btn.danger { background: linear-gradient(135deg, #ef4444, #f87171); border: none; color: #fff; box-shadow: 0 6px 18px rgba(239, 68, 68, .3); }
.btn.danger-ghost { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.btn.ghost { background: var(--primary-light); border-color: transparent; color: var(--primary); }
.btn.ghost:hover { background: #e0e7ff; }
.btn.full { width: 100%; margin-top: 4px; }
.btn.small { padding: 8px 14px; font-size: 14px; }
.btn + .btn { margin-top: 10px; }
.file-btn { margin-top: 10px; }

.icon-btn {
  border: none; background: var(--primary-light); color: var(--primary);
  border-radius: 8px; padding: 5px 12px; font-size: 12px; font-weight: 600;
  transition: all .15s;
}
.icon-btn:hover { background: #e0e7ff; }

/* ================= 表单 ================= */
.field { display: block; margin-bottom: 14px; position: relative; }
.field > span {
  display: block; font-size: 13px; font-weight: 600;
  color: var(--text-2); margin-bottom: 6px;
}
.field input, .inline-field input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  font-size: 15px;
  background: #fafbfd;
  outline: none;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.field input:focus, .inline-field input:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}
.inline-field { display: flex; gap: 8px; }
.inline-field input { flex: 1; }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-bottom: 6px; }
.field-status { font-size: 12px; margin-top: 6px; min-height: 16px; }
.form-card { padding: 18px 16px; }
.check-line {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--text-2);
  margin: 4px 0 12px; cursor: pointer; user-select: none;
}
.check-line input { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

/* 联想下拉 */
.suggest {
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
  padding: 4px;
}
.suggest.show { display: block; animation: dropIn .15s ease; }
.suggest-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 10px 12px;
  border: none; background: none; font-size: 14px;
  border-radius: 8px;
}
.suggest-item:active, .suggest-item:hover { background: var(--primary-light); }
.suggest-empty, .drop-empty {
  padding: 12px; text-align: center; color: var(--text-3); font-size: 13px;
}

/* ================= 登录页 ================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(150deg, #4f46e5 0%, #7c3aed 55%, #a855f7 100%);
  position: relative;
  overflow: hidden;
}
.login-wrap::before, .login-wrap::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  pointer-events: none;
}
.login-wrap::before { width: 320px; height: 320px; top: -100px; right: -80px; }
.login-wrap::after { width: 240px; height: 240px; bottom: -70px; left: -60px; }
.login-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: rgba(255, 255, 255, .97);
  backdrop-filter: blur(10px);
  border-radius: 24px;
  padding: 34px 24px 24px;
  box-shadow: 0 24px 60px rgba(30, 20, 80, .35);
  text-align: center;
  animation: loginIn .4s ease;
}
@keyframes loginIn {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to { opacity: 1; transform: none; }
}
.login-logo {
  width: 64px; height: 64px;
  margin: 0 auto 14px;
  border-radius: 20px;
  background: var(--grad);
  box-shadow: var(--shadow-primary);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.login-logo svg { width: 34px; height: 34px; }
.login-card h1 { margin: 0; font-size: 22px; font-weight: 800; }
.login-tip { color: var(--text-2); font-size: 13px; margin: 6px 0 22px; }
.login-card form { text-align: left; }
.login-card .btn { margin-top: 6px; }
.login-note {
  color: var(--text-3); font-size: 12px;
  margin: 16px 0 0; line-height: 1.8;
}

/* ================= 搜索栏 ================= */
.search-bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  transition: border-color .15s, box-shadow .15s;
}
.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}
.search-bar svg { width: 17px; height: 17px; color: var(--text-3); flex-shrink: 0; }
.search-bar input {
  flex: 1; border: none; outline: none; font-size: 15px;
  background: transparent; min-width: 0;
}
.search-drop {
  position: absolute;
  left: 0; right: 0; top: calc(100% + 6px);
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  padding: 4px;
}
.search-drop.show { display: block; animation: dropIn .15s ease; }
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
.drop-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 11px 12px;
  border: none; background: none; font-size: 14px;
  border-radius: 9px;
}
.drop-item:active, .drop-item:hover { background: var(--primary-light); }
.di-name { font-weight: 600; }
.di-id { color: var(--text-3); font-size: 12px; }

/* ================= 分组卡片 ================= */
.group {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid rgba(232, 234, 242, .8);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
  transition: box-shadow .2s;
}
.group:hover { box-shadow: 0 4px 20px rgba(30, 34, 53, .1); }
.group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 14px;
  background: linear-gradient(135deg, var(--primary-light), #f5f3ff);
  border-bottom: 1px solid var(--line);
}
.g-title {
  font-weight: 700; font-size: 14px; color: var(--primary-dark);
  display: flex; align-items: center; gap: 7px;
}
.g-title::before {
  content: "";
  width: 4px; height: 14px;
  border-radius: 4px;
  background: var(--grad);
}
.g-count {
  font-size: 12px; color: var(--primary-dark); font-weight: 600;
  background: #fff; border-radius: 20px; padding: 2px 11px;
  box-shadow: 0 1px 3px rgba(99, 102, 241, .15);
}

.group-body {
  padding: 12px;
}

/* 详情卡片：插在所选人名所在行的下方，占满整行 */
.detail {
  grid-column: 1 / -1;
  min-width: 0;
  background: linear-gradient(180deg, #fafbff, #f6f7fd);
  border: 1px solid #e3e6f5;
  border-radius: 14px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  animation: detailIn .22s ease;
}
@keyframes detailIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}

.card-top { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--grad);
  box-shadow: 0 3px 10px rgba(99, 102, 241, .35);
  color: #fff;
  font-size: 19px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.avatar.sm { width: 38px; height: 38px; font-size: 16px; }
.avatar.big { width: 54px; height: 54px; font-size: 23px; }
.card-title { flex: 1; min-width: 0; }
.p-name { font-size: 17px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-id { font-size: 12px; color: var(--text-2); }

.info-row {
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
}
.info-label { font-size: 12px; color: var(--text-2); flex-shrink: 0; }
.info-value { font-size: 13px; font-weight: 600; text-align: right; word-break: break-all; }

.info-block {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-meta { font-size: 11px; color: var(--text-3); text-align: right; }

/* 推荐的人：全部展示（不分页） */
.ref-grid {
  margin-top: 2px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--primary-light);
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 7px 4px;
  min-width: 0;
  gap: 1px;
  transition: all .15s;
}
.chip:hover { border-color: #c7d2fe; background: #e0e7ff; }
.chip:active { opacity: .75; }
.chip-name {
  font-size: 13px; font-weight: 600; color: var(--primary-dark);
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-id { font-size: 11px; color: var(--text-2); }

/* 成员名单：每行 4 人，平分宽度 */
.names {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.name-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 7px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  transition: all .15s;
}
.name-btn:hover {
  border-color: #c7d2fe;
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(99, 102, 241, .12);
}
.name-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .12);
}
.name-btn.flash { animation: flash 1.5s; }
@keyframes flash {
  0%, 60% { box-shadow: 0 0 0 3px rgba(99, 102, 241, .35); }
  100% { box-shadow: none; }
}
.nb-name {
  font-size: 13px; font-weight: 600;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  align-self: stretch;
}
.nb-id { font-size: 11px; color: var(--text-3); }
.name-btn.active .nb-id { color: var(--primary); }

/* ================= 我的推荐列表（手风琴） ================= */
.ref-acc { padding: 0; overflow: hidden; }
.ref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: none;
  background: none;
  text-align: left;
  padding: 13px 14px;
  transition: background .15s;
}
.ref-item:hover { background: #f8f9ff; }
.ref-acc.open .ref-item {
  border-bottom: 1px solid var(--line);
  background: var(--primary-light);
}
.ref-acc.open .ri-arrow { color: var(--primary); }
.ri-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.ri-name { font-size: 15px; font-weight: 700; }
.ri-sub { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.ri-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.ri-id { color: var(--text-3); font-size: 13px; font-weight: 600; }
.ri-arrow {
  width: 18px; height: 18px;
  color: var(--text-3);
  transition: transform .3s ease;
}
.ref-acc.open .ri-arrow { transform: rotate(180deg); }
.acc-body {
  max-height: 0;
  overflow: hidden;
  transition: max-height .3s ease;
}
.ref-acc.open .acc-body { max-height: 480px; }
.acc-inner {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ================= 我的页 ================= */
.me-card {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 16px;
  background: linear-gradient(135deg, #ffffff, #f6f6ff);
}

/* ================= 弹层 ================= */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(23, 26, 45, .5);
  backdrop-filter: blur(3px);
  z-index: 90;
  opacity: 0;
  transition: opacity .2s;
}
.sheet {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 100;
  max-width: 640px;
  margin: 0 auto;
  background: #fff;
  border-radius: 22px 22px 0 0;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.32, .72, .35, 1);
  box-shadow: 0 -10px 40px rgba(30, 34, 53, .2);
}
.sheet.open { transform: translateY(0); }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  position: relative;
}
.sheet-head::before {
  content: "";
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 38px; height: 4px;
  border-radius: 4px;
  background: #dfe1ec;
}
.sheet-title { font-size: 16px; font-weight: 700; }
.sheet-close {
  border: none; background: #f3f4f6;
  width: 28px; height: 28px;
  border-radius: 50%;
  font-size: 18px;
  color: var(--text-2);
  line-height: 1;
  transition: all .15s;
}
.sheet-close:hover { background: #e5e7eb; color: var(--text); }
.sheet-body {
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  overflow-y: auto;
}
.confirm-box .confirm-text {
  margin: 4px 0 14px;
  font-size: 14px;
  color: var(--text);
  line-height: 1.7;
}

/* ================= Toast ================= */
.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -80px);
  z-index: 200;
  max-width: 86vw;
  background: rgba(30, 34, 53, .92);
  backdrop-filter: blur(8px);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all .28s cubic-bezier(.32, .72, .35, 1);
  text-align: center;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { background: rgba(30, 34, 53, .92); }
.toast.err { background: rgba(220, 38, 38, .95); }

/* ================= 超窄屏微调 ================= */
@media (max-width: 355px) {
  .nb-name { font-size: 12px; }
  .page { padding: 12px 8px 0; }
}

/* 桌面端：加宽留白更舒适 */
@media (min-width: 641px) {
  .page { padding: 24px 20px 0; }
  .sheet { border-radius: 22px; bottom: 24px; left: 24px; right: 24px; margin: 0 auto; }
  .sheet-head::before { display: none; }
}
