/* ================= 基础 ================= */
:root {
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-light: #eef2ff;
  --bg: #f3f4f6;
  --card: #ffffff;
  --text: #111827;
  --text-2: #6b7280;
  --text-3: #9ca3af;
  --line: #e5e7eb;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(17, 24, 39, .08), 0 1px 2px rgba(17, 24, 39, .04);
  --shadow-lg: 0 10px 30px rgba(17, 24, 39, .15);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  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; }

/* ================= 页面骨架 ================= */
.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 12px 0;
  min-height: 100vh;
}
.page-pad { height: calc(76px + env(safe-area-inset-bottom)); }

.page-head { padding: 6px 2px 12px; }
.page-head h1 { margin: 0; font-size: 22px; font-weight: 700; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 3px; }
.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, .96);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  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;
}
.tabbar .tab svg { width: 22px; height: 22px; }
.tabbar .tab.active { color: var(--primary); font-weight: 600; }

/* ================= 卡片与通用 ================= */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px;
  margin-bottom: 12px;
}
.card-title-bar {
  font-weight: 700; font-size: 15px; margin-bottom: 10px;
}
.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: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  transition: opacity .15s, transform .05s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-ghost { background: transparent; border-color: #fecaca; color: var(--danger); }
.btn.ghost { background: var(--primary-light); border-color: transparent; color: var(--primary); }
.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 10px; font-size: 12px; font-weight: 600;
}

/* ================= 表单 ================= */
.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: 10px;
  padding: 11px 12px;
  font-size: 15px;
  background: #fafafa;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus, .inline-field input:focus {
  border-color: var(--primary);
  background: #fff;
}
.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: 16px 14px; }

/* 联想下拉 */
.suggest {
  position: absolute;
  left: 0; right: 0; top: 100%;
  z-index: 30;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow-y: auto;
  display: none;
  margin-top: 4px;
}
.suggest.show { display: block; }
.suggest-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 10px 12px;
  border: none; background: none; font-size: 14px;
}
.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(160deg, #4f46e5 0%, #7c3aed 100%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #fff;
  border-radius: 20px;
  padding: 30px 22px 22px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.login-logo {
  width: 60px; height: 60px;
  margin: 0 auto 12px;
  border-radius: 18px;
  background: var(--primary-light);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
}
.login-logo svg { width: 32px; height: 32px; }
.login-card h1 { margin: 0; font-size: 21px; }
.login-tip { color: var(--text-2); font-size: 13px; margin: 6px 0 20px; }
.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: 12px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.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: 12px;
  box-shadow: var(--shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  display: none;
}
.search-drop.show { display: block; }
.drop-item {
  display: flex; justify-content: space-between; align-items: center;
  width: 100%; padding: 11px 14px;
  border: none; background: none; font-size: 14px;
}
.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);
  box-shadow: var(--shadow);
  margin-bottom: 14px;
  overflow: hidden;
}
.group-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: linear-gradient(135deg, var(--primary-light), #faf5ff);
  border-bottom: 1px solid var(--line);
}
.g-title { font-weight: 700; font-size: 14px; color: var(--primary-dark); }
.g-count { font-size: 12px; color: var(--text-2); background: #fff; border-radius: 20px; padding: 2px 10px; }

.group-body {
  display: flex;
  gap: 10px;
  padding: 12px;
  align-items: stretch;
}

/* 左侧：详情卡片 */
.detail {
  flex: 1 1 auto;
  min-width: 0;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-top { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  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: 10px;
  padding: 8px 10px;
}
.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: 10px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.card-meta { font-size: 11px; color: var(--text-3); text-align: right; }

/* 推荐的人：左右滑动分页 */
.ref-pager { margin-top: 2px; }
.ref-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.ref-track::-webkit-scrollbar { display: none; }
.ref-page {
  flex: 0 0 100%;
  scroll-snap-align: start;
  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: none;
  border-radius: 10px;
  padding: 7px 4px;
  min-width: 0;
  gap: 1px;
}
.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); }

.ref-dots {
  display: flex; justify-content: center; gap: 5px;
  padding-top: 4px;
}
.ref-dots .dot {
  width: 5px; height: 5px;
  border-radius: 3px;
  background: var(--line);
  transition: all .2s;
}
.ref-dots .dot.active {
  width: 14px;
  background: var(--primary);
}

/* 右侧：成员名单 */
.names {
  flex: 0 0 138px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.name-btn {
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  transition: all .15s;
}
.name-btn.active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.name-btn.flash { animation: flash 1.5s; }
@keyframes flash {
  0%, 60% { box-shadow: 0 0 0 3px rgba(79, 70, 229, .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;
}
.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: 16px 14px;
}

/* ================= 弹层 ================= */
.sheet-mask {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, .45);
  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: 18px 18px 0 0;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform .25s ease-out;
}
.sheet.open { transform: translateY(0); }
.sheet-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.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;
}
.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: #111827;
  color: #fff;
  font-size: 14px;
  padding: 10px 18px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all .25s;
  text-align: center;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }
.toast.ok { background: #111827; }
.toast.err { background: var(--danger); }

/* ================= 超窄屏微调 ================= */
@media (max-width: 355px) {
  .names { flex-basis: 120px; }
  .nb-name { font-size: 12px; }
  .page { padding: 12px 8px 0; }
}

/* 桌面端：加宽留白更舒适 */
@media (min-width: 641px) {
  .page { padding: 24px 20px 0; }
  .sheet { border-radius: 18px; bottom: 24px; left: 24px; right: 24px; margin: 0 auto; }
}
