:root {
  --ink: #1f2937;
  --ink-2: #4b5563;
  --ink-3: #8a94a6;
  --line: #e5e7eb;
  --bg: #f5f6f8;
  --card: #ffffff;
  --brand: #165d67;
  --brand-2: #0f444c;
  --brand-soft: #e6f2f3;
  --accent: #c2703d;
  --accent-soft: #fdf1e7;
  --ok: #2f855a;
  --danger: #c0392b;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 20px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }

.wrap { max-width: 980px; margin: 0 auto; padding: 0 16px 64px; }

/* ---------- header ---------- */
.hero {
  background: linear-gradient(135deg, var(--brand-2) 0%, var(--brand) 55%, #2a7f8c 100%);
  color: #fff;
  padding: 26px 16px 30px;
  margin-bottom: 18px;
}
.hero-inner { max-width: 980px; margin: 0 auto; }
.hero h1 { margin: 0; font-size: 24px; letter-spacing: 2px; font-weight: 700; }
.hero p { margin: 6px 0 0; font-size: 13px; opacity: .85; }
.hero-logo {
  width: 64px; height: 64px; border-radius: 50%; object-fit: cover; flex: 0 0 auto;
  border: 2px solid rgba(255, 255, 255, .75); box-shadow: 0 4px 14px rgba(0, 0, 0, .25);
  background: #fff;
}
.hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.hero-badge {
  display: inline-block; background: rgba(255, 255, 255, .16); border: 1px solid rgba(255, 255, 255, .28);
  padding: 3px 10px; border-radius: 999px; font-size: 12px; margin-bottom: 8px;
}

/* ---------- card ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 15px; font-weight: 700; margin: 0 0 14px; color: var(--ink);
  display: flex; align-items: center; gap: 8px;
}
.card-title .bar { width: 3px; height: 15px; background: var(--brand); border-radius: 2px; }
.card-title small { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: auto; }

/* ---------- form ---------- */
.field { margin-bottom: 16px; }
.label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 7px; color: var(--ink); }
.label .req { color: var(--danger); margin-left: 2px; }
.label .hint { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: 6px; }

input[type=text], input[type=tel], input[type=number], input[type=password], select, textarea {
  width: 100%; padding: 10px 12px; font-size: 15px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s; font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 93, 103, .1);
}
select { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%238a94a6' stroke-width='1.6' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
textarea { resize: vertical; min-height: 68px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* chips */
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; font-size: 14px; color: var(--ink-2); cursor: pointer; user-select: none;
  transition: all .15s;
}
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-2); font-weight: 600; }
.chip .tick { width: 15px; height: 15px; border-radius: 4px; border: 1.5px solid #cbd5e1; display: inline-block; position: relative; }
.chip.on .tick { background: var(--brand); border-color: var(--brand); }
.chip.on .tick::after { content: ''; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 11px 20px; border: none; border-radius: 10px; font-size: 15px; font-weight: 600;
  background: var(--brand); color: #fff; cursor: pointer; transition: background .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:hover { background: var(--brand-2); }
.btn.block { width: 100%; }
.btn.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.btn.ghost:hover { background: var(--brand-soft); }
.btn.sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.msg { padding: 10px 13px; border-radius: 10px; font-size: 14px; margin-bottom: 14px; display: none; }
.msg.err { display: block; background: #fdecea; color: #a1291b; border: 1px solid #f7c5bd; }
.msg.ok { display: block; background: #e8f5ee; color: #1e6b45; border: 1px solid #b7e0c8; }
.msg.info { display: block; background: var(--brand-soft); color: var(--brand-2); border: 1px solid #c5e2e5; }

/* ---------- stats ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
@media (max-width: 720px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .n { font-size: 26px; font-weight: 700; color: var(--brand); line-height: 1.2; }
.kpi .t { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.filters .f { flex: 1 1 140px; min-width: 130px; }
.filters .f label { display: block; font-size: 12px; color: var(--ink-3); margin-bottom: 4px; }
.filters .btn { flex: 0 0 auto; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 860px) { .chart-grid { grid-template-columns: 1fr; } }
.chart-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 16px 10px; cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.chart-card:hover { border-color: var(--brand); box-shadow: 0 4px 22px rgba(22, 93, 103, .14); }
.chart-card .ct { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.chart-card .ct .bar { width: 3px; height: 14px; background: var(--accent); border-radius: 2px; }
.chart-card .cs { font-size: 12px; color: var(--ink-3); margin: 2px 0 6px; }
.chart { width: 100%; height: 260px; touch-action: manipulation; }
.chart.tall { height: 340px; }

/* 地图下方的省份快捷标签（手机上点色块太小，用它兜底） */
.pchips { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; }
.pchip-lb { font-size: 12px; color: var(--ink-3); align-self: center; margin-right: 2px; }
.pchip {
  border: 1px solid #d5e3e6; background: #f4f9fa; color: var(--brand);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; line-height: 1.4;
  cursor: pointer; font-family: inherit; -webkit-appearance: none; appearance: none;
}
.pchip:hover { background: #e6f2f4; border-color: var(--brand); }
.pchip:active { background: #d9ebee; }

/* ---------- drawer ---------- */
.mask { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 40; }
.mask.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(560px, 100%);
  background: #fff; z-index: 50; transform: translateX(100%); transition: transform .25s ease;
  display: flex; flex-direction: column; box-shadow: -6px 0 30px rgba(16, 24, 40, .16);
}
.drawer.on { transform: translateX(0); }
.drawer-hd { padding: 16px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-hd h3 { margin: 0; font-size: 16px; }
.drawer-hd .sub { font-size: 12px; color: var(--ink-3); }
.drawer-hd .x { margin-left: auto; border: none; background: #f1f3f5; width: 30px; height: 30px; border-radius: 8px; cursor: pointer; font-size: 17px; color: var(--ink-2); }
.drawer-bd { flex: 1; overflow-y: auto; padding: 14px 18px 24px; -webkit-overflow-scrolling: touch; }

.person {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-bottom: 10px; background: #fcfdfd;
}
.person .top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.person .nm { font-size: 16px; font-weight: 700; }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-2); }
.tag.y { background: var(--accent-soft); color: var(--accent); }
.tag.g { background: #e8f5ee; color: var(--ok); }
.person .kv { margin-top: 6px; font-size: 13px; color: var(--ink-2); display: grid; grid-template-columns: 76px 1fr; row-gap: 3px; }
.person .kv b { font-weight: 500; color: var(--ink-3); }
.person .kv a { color: var(--brand); }

.empty { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 14px; }

/* ---------- table ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 860px; }
table.tbl th, table.tbl td { border-bottom: 1px solid var(--line); padding: 8px 10px; text-align: left; white-space: nowrap; }
table.tbl th { background: #f8f9fa; color: var(--ink-2); font-weight: 600; position: sticky; top: 0; }
table.tbl td.act { white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0 4px; }
.link-btn.danger { color: var(--danger); }

.foot { text-align: center; color: var(--ink-3); font-size: 12px; padding: 10px 0 0; }
.foot a { color: var(--brand); }

/* 页面底部管理员入口：低调但一眼能找到 */
.site-foot {
  margin-top: 22px; padding: 14px 0 4px; text-align: center;
  border-top: 1px dashed var(--line, #e3e8ef);
}
.site-foot a {
  display: inline-block; color: var(--ink-2); font-size: 13px; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: #c3ccd8; padding: 6px 10px;
}
.site-foot a:hover { color: var(--brand); text-decoration-color: var(--brand); }

/* ---------- 顶部菜单 ---------- */
.nav { background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
.nav-inner { max-width: 980px; margin: 0 auto; padding: 8px 16px; display: flex; gap: 8px; overflow-x: auto; }
.nav-item {
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  padding: 7px 14px; border-radius: 999px; font-size: 14px; font-weight: 600;
  color: var(--ink-2); border: 1px solid transparent;
}
.nav-item svg { width: 16px; height: 16px; flex: 0 0 auto; }
.nav-item:hover { background: var(--bg); }
.nav-item.on { background: var(--brand-soft); color: var(--brand); border-color: #cbe4e7; }

/* ---------- 树洞 ---------- */
.th-composer textarea {
  width: 100%; min-height: 92px; resize: vertical; font-family: inherit; font-size: 16px;
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; color: var(--ink); background: #fbfcfd;
}
.th-composer textarea:focus { outline: none; border-color: var(--brand); background: #fff; }
.th-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.th-previews { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; margin-top: 10px; }
.th-prev { position: relative; }
.th-prev img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; display: block; border: 1px solid var(--line); }
.th-prev button {
  position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%;
  border: none; background: rgba(0,0,0,.6); color: #fff; font-size: 14px; line-height: 22px; padding: 0; cursor: pointer;
}
.th-count { font-size: 12px; color: var(--ink-3); }

.th-post { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.th-head { display: flex; align-items: center; gap: 10px; }
.th-avatar {
  width: 40px; height: 40px; border-radius: 50%; background: var(--brand); color: #fff; display: flex;
  align-items: center; justify-content: center; font-size: 17px; font-weight: 700; flex: 0 0 auto;
}
.th-meta { flex: 1; min-width: 0; }
.th-name { font-weight: 700; font-size: 15px; }
.th-time { font-size: 12px; color: var(--ink-3); }
.th-text { margin: 10px 0 0; white-space: pre-wrap; word-break: break-word; line-height: 1.75; }
.th-imgs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.th-imgs.one { grid-template-columns: repeat(2, 1fr); max-width: 330px; }
.th-imgs img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; cursor: zoom-in; display: block; background: var(--bg); }
.th-del { font-size: 12px; color: var(--ink-3); background: none; border: none; cursor: pointer; padding: 4px 6px; }
.th-del:hover { color: var(--danger); }

.th-comments { margin-top: 12px; border-top: 1px solid var(--line); padding-top: 10px; }
.th-cm { display: flex; gap: 8px; padding: 6px 0; align-items: flex-start; }
.th-cm .bd { flex: 1; min-width: 0; }
.th-cm .nm { font-size: 13px; font-weight: 700; color: var(--brand); }
.th-cm .tx { font-size: 14px; word-break: break-word; white-space: pre-wrap; }
.th-cm .tm { font-size: 11px; color: var(--ink-3); margin-top: 2px; }
.th-cm-form { display: flex; gap: 8px; margin-top: 8px; }
.th-cm-form input {
  flex: 1; border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-size: 16px; font-family: inherit; background: #fbfcfd;
}
.th-cm-form input:focus { outline: none; border-color: var(--brand); background: #fff; }

.th-lightbox {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.92);
  display: none; align-items: center; justify-content: center; padding: 16px;
}
.th-lightbox.on { display: flex; }
.th-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }

/* ---------- 移动端适配 ---------- */
@media (max-width: 640px) {
  body { font-size: 16px; }
  .hero { padding: 20px 16px 22px; }
  .hero h1 { font-size: 20px; letter-spacing: 1px; }
  .hero-logo { width: 52px; height: 52px; }
  .wrap { padding: 0 12px 48px; }
  .card { padding: 15px 13px; border-radius: 12px; }
  /* iOS 聚焦时字号 <16px 会自动放大页面 */
  input[type=text], input[type=tel], input[type=number], input[type=password], select, textarea { font-size: 16px; }
  .chip { padding: 11px 16px; }
  .btn { padding: 13px 20px; }
  .kpis { gap: 8px; }
  .kpi { padding: 12px 13px; }
  .kpi .n { font-size: 22px; }
  .chart { height: 230px; }
  /* 手机上地图给足高度，省份色块才点得中 */
  .chart.tall { height: 360px; }
  .pchip { padding: 8px 14px; font-size: 14px; }
  .chart-card { padding: 14px 12px 8px; }
  .filters .f { flex: 1 1 46%; }
  .drawer { width: 100%; }
  .person .kv { grid-template-columns: 68px 1fr; font-size: 14px; }
  .gate { padding: 16px; }
  .gate-box { padding: 22px 18px 18px; }
  .gate-logo { width: 62px; height: 62px; margin-bottom: 10px; }
  /* 手机端留出底部空间，避免微信工具栏遮住管理员入口 */
  .site-foot { margin-top: 26px; padding-bottom: 26px; }
  .nav-inner { padding: 6px 12px; gap: 6px; }
  .nav-item { padding: 6px 11px; font-size: 13px; }
  .th-imgs { gap: 4px; }
  .th-post { padding: 14px; }
  .th-avatar { width: 36px; height: 36px; font-size: 15px; }
}

/* ---------- 邀请码门 ---------- */
.gate {
  position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    linear-gradient(165deg, rgba(15, 68, 76, .60) 0%, rgba(22, 93, 103, .32) 45%, rgba(10, 40, 46, .66) 100%),
    url('/bg.jpg') center/cover no-repeat;
}
.gate-box {
  width: 100%; max-width: 360px; border-radius: 18px; padding: 28px 24px 22px; text-align: center;
  /* 半透明 + 毛玻璃：透出后面的校园背景，同时保证文字可读 */
  background: rgba(255, 255, 255, .76);
  border: 1px solid rgba(255, 255, 255, .55);
  box-shadow: 0 20px 50px rgba(0, 0, 0, .28);
}
@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .gate-box {
    background: rgba(255, 255, 255, .58);
    -webkit-backdrop-filter: blur(14px) saturate(150%);
    backdrop-filter: blur(14px) saturate(150%);
  }
}
.gate-logo {
  width: 78px; height: 78px; border-radius: 50%; object-fit: cover; display: block; margin: 0 auto 14px;
  border: 3px solid #fff; box-shadow: 0 6px 18px rgba(0, 0, 0, .18); background: #fff;
}
.gate-badge {
  display: inline-block; font-size: 11px; color: var(--brand-2); background: var(--brand-soft);
  border: 1px solid #c5e2e5; padding: 3px 10px; border-radius: 999px; margin-bottom: 12px;
}
.gate-box h2 { margin: 0 0 6px; font-size: 22px; letter-spacing: 2px; color: var(--ink); }
.gate-sub { margin: 0 0 18px; font-size: 13px; color: var(--ink-2); }
.gate-box input { text-align: center; letter-spacing: 2px; margin-bottom: 12px; background: rgba(255, 255, 255, .88); }
.gate-err { color: var(--danger); font-size: 13px; min-height: 20px; margin: 8px 0 0; }
.gate-tip { color: var(--ink-2); font-size: 12px; margin: 4px 0 0; }

.toast {
  position: fixed; left: 50%; top: 22px; transform: translateX(-50%) translateY(-16px);
  background: rgba(31, 41, 55, .93); color: #fff; padding: 9px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .22s; z-index: 90;
}
.toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }
