/* ==========================================================
   全国高校投票活动 · 移动端样式（微信内置浏览器优先）
   原则：不引入任何 CSS 框架，总包体控制在 20KB 内
   ========================================================== */

:root {
  --brand: #1a3d7c;
  --brand-light: #2c5aa0;
  --gold: #c8952e;
  --gold-light: #f4e6c8;
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #1f2329;
  --text-sub: #6b7280;
  --text-hint: #9ca3af;
  --line: #e8eaed;
  --danger: #d93025;
  --success: #16a34a;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { 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", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; display: block; }

button {
  font-family: inherit;
  font-size: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

.hidden { display: none !important; }

/* ---------- 通用卡片 ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  margin: 12px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.section-title::before {
  content: "";
  width: 3px;
  height: 15px;
  background: var(--brand);
  border-radius: 2px;
}

/* ---------- 介绍页 ---------- */
.hero {
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-light) 55%, #3b6bb5 100%);
  color: #fff;
  padding: 40px 20px 56px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.hero::after {
  content: "";
  position: absolute;
  left: -20%;
  right: -20%;
  bottom: -30px;
  height: 60px;
  background: var(--bg);
  border-radius: 50% 50% 0 0;
}

.hero h1 {
  font-size: 24px;
  margin: 0 0 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.hero .sub {
  font-size: 13px;
  opacity: 0.85;
  margin: 0;
}

.hero .badge {
  display: inline-block;
  margin-top: 14px;
  padding: 5px 14px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 20px;
  font-size: 12px;
}

.intro-text {
  font-size: 14px;
  color: #374151;
  line-height: 1.85;
  margin: 0;
  white-space: pre-wrap;
}

.rule-list {
  margin: 0;
  padding-left: 20px;
  font-size: 14px;
  color: #374151;
  line-height: 1.9;
}

.rule-list li { margin-bottom: 4px; }

.notice {
  background: var(--gold-light);
  border-left: 3px solid var(--gold);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: #7a5a12;
  line-height: 1.7;
}

.footer-note {
  text-align: center;
  font-size: 12px;
  color: var(--text-hint);
  padding: 16px 24px calc(90px + var(--safe-bottom));
  line-height: 1.8;
}

/* ---------- 固定底部按钮 ---------- */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 10px 16px calc(10px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  z-index: 20;
}

.btn-primary {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--brand);
  color: #fff;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
}

.btn-primary:active { background: #142f5e; }

.btn-primary[disabled] {
  background: #c9cdd4;
  cursor: not-allowed;
}

/* ---------- 投票页布局 ---------- */
.vote-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.vote-header {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.vote-header .title {
  font-size: 16px;
  font-weight: 600;
}

.quota-pill {
  font-size: 12px;
  background: rgba(255, 255, 255, 0.18);
  padding: 4px 10px;
  border-radius: 12px;
}

.quota-pill b { color: #ffd970; font-size: 14px; }

/* 榜单横条 */
.rank-strip {
  background: #fff;
  flex-shrink: 0;
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--line);
}

.rank-strip .head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px 6px;
  font-size: 12px;
  color: var(--text-sub);
}

.rank-strip .head .more {
  color: var(--brand);
  font-size: 12px;
}

.rank-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
  font-size: 13px;
}

.rank-row .no {
  width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 700;
  background: #eef1f6;
  color: var(--text-sub);
  flex-shrink: 0;
}

.rank-row .no.top1 { background: var(--gold); color: #fff; }
.rank-row .no.top2 { background: #b8c0cc; color: #fff; }
.rank-row .no.top3 { background: #cd9b6a; color: #fff; }

.rank-row .name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rank-row .votes {
  color: var(--gold);
  font-weight: 600;
  font-size: 12px;
  flex-shrink: 0;
}

/* 我的状态 */
.my-status {
  background: #fbfaf6;
  border-bottom: 1px solid var(--line);
  padding: 8px 16px;
  font-size: 12px;
  color: #7a5a12;
  flex-shrink: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.my-status .chip {
  background: #fff;
  border: 1px solid #eadfc4;
  border-radius: 10px;
  padding: 2px 8px;
}

/* 搜索 */
.search-wrap {
  padding: 10px 16px;
  background: #fff;
  flex-shrink: 0;
}

.search-box {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 18px;
  padding: 8px 14px;
  gap: 8px;
}

.search-box input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--text);
}

.search-box input::placeholder { color: var(--text-hint); }

.search-box .clear {
  font-size: 12px;
  color: var(--text-hint);
  padding: 2px 4px;
}

/* 省份标签 */
.province-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  scrollbar-width: none;
}

.province-bar::-webkit-scrollbar { display: none; }

.province-bar .tag {
  flex-shrink: 0;
  padding: 5px 13px;
  border-radius: 14px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-sub);
  white-space: nowrap;
}

.province-bar .tag.active {
  background: var(--brand);
  color: #fff;
  font-weight: 500;
}

/* 学校列表（虚拟滚动容器） */
.list-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
  background: #fff;
}

.list-spacer { position: relative; }

.school-row {
  position: absolute;
  left: 0;
  right: 0;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid #f2f3f5;
  background: #fff;
}

.school-row .info { flex: 1; min-width: 0; }

.school-row .sname {
  font-size: 15px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.school-row .smeta {
  font-size: 12px;
  color: var(--text-hint);
  margin-top: 1px;
}

.school-row .svote {
  font-size: 12px;
  color: var(--gold);
  font-weight: 600;
  min-width: 44px;
  text-align: right;
  flex-shrink: 0;
}

.vote-btn {
  flex-shrink: 0;
  padding: 7px 18px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 600;
  background: var(--brand);
  color: #fff;
  min-width: 64px;
}

.vote-btn:active { background: #142f5e; }

.vote-btn.voted {
  background: #eef1f6;
  color: var(--text-hint);
  font-weight: 400;
}

.vote-btn:disabled {
  background: #eef1f6;
  color: var(--text-hint);
  font-weight: 400;
}

.empty-tip {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-hint);
  font-size: 14px;
}

/* 浮动提示 */
.toast {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 100;
  max-width: 78%;
  text-align: center;
  line-height: 1.5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}

.toast.show { opacity: 1; }

/* 加载遮罩 */
.loading {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  z-index: 90;
  font-size: 13px;
  color: var(--text-sub);
}

.spinner {
  width: 26px;
  height: 26px;
  border: 2.5px solid #e5e7eb;
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 后台 ---------- */
.admin-body {
  background: #eef0f4;
  min-height: 100vh;
  font-size: 14px;
}

.admin-login {
  max-width: 360px;
  margin: 0 auto;
  padding: 60px 24px;
}

.admin-login h1 {
  font-size: 20px;
  text-align: center;
  margin-bottom: 28px;
  color: var(--brand);
}

.field {
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--text-sub);
  margin-bottom: 5px;
}

.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d8dce3;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  background: #fff;
}

.field input:focus, .field textarea:focus {
  border-color: var(--brand);
}

.admin-topbar {
  background: var(--brand);
  color: #fff;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}

.admin-topbar .who { font-size: 12px; opacity: 0.8; }

.tabs {
  display: flex;
  background: #fff;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  position: sticky;
  top: 48px;
  z-index: 9;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar { display: none; }

.tabs .tab {
  flex-shrink: 0;
  padding: 11px 16px;
  font-size: 13px;
  color: var(--text-sub);
  border-bottom: 2px solid transparent;
}

.tabs .tab.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
  font-weight: 600;
}

.panel { display: none; padding: 12px; }
.panel.active { display: block; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.stat-box {
  background: #fff;
  border-radius: 10px;
  padding: 12px 14px;
}

.stat-box .k { font-size: 12px; color: var(--text-sub); }

.stat-box .v {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand);
  margin-top: 2px;
}

.stat-box .v.small { font-size: 14px; font-weight: 600; }

.admin-card {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
}

.admin-card h3 {
  font-size: 14px;
  margin: 0 0 10px;
  font-weight: 600;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.admin-table th, .admin-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid #f0f1f4;
  white-space: nowrap;
}

.admin-table th {
  color: var(--text-sub);
  font-weight: 500;
  font-size: 12px;
  background: #fafbfc;
  position: sticky;
  top: 0;
}

.admin-table-wrap {
  max-height: 60vh;
  overflow: auto;
  border-radius: 8px;
}

.admin-table .num { text-align: right; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 11px;
}

.badge.on { background: #e7f6ec; color: var(--success); }
.badge.off { background: #fbeaea; color: var(--danger); }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  background: var(--brand);
  color: #fff;
}

.btn.ghost {
  background: #fff;
  color: var(--brand);
  border: 1px solid #cfd6e4;
}

.btn.danger { background: var(--danger); }
.btn.small { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn:disabled { opacity: 0.5; }

.row-actions { display: flex; gap: 6px; }

.inline-form {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.inline-form .field { flex: 1; min-width: 120px; margin-bottom: 0; }

.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }

.hint-text {
  font-size: 12px;
  color: var(--text-hint);
  line-height: 1.7;
  margin: 6px 0 0;
}

@media (min-width: 720px) {
  .admin-body { max-width: 900px; margin: 0 auto; background: #eef0f4; }
}

/* ============================================================
   介绍页 / 投票页之间的衔接元素
   ============================================================ */

/* 介绍页按钮在活动未开始/已结束时的禁用态 */
.btn-primary.disabled,
.btn-primary.disabled:active {
  background: #c7cdd6;
  color: #fff;
  box-shadow: none;
  cursor: default;
  transform: none;
}

/* 投票页顶部返回介绍页的入口 */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: rgba(255, 255, 255, 0.9);
  font-size: 13px;
  padding: 4px 8px 4px 2px;
  flex-shrink: 0;
}

.back-link .arrow {
  font-size: 18px;
  line-height: 1;
  margin-top: -2px;
}

.back-link:active { opacity: 0.6; }

/* 活动未开始 / 已结束横幅 */
.state-banner {
  flex-shrink: 0;
  padding: 9px 14px;
  font-size: 13px;
  line-height: 1.5;
  background: #fff7e6;
  color: #a35b00;
  border-bottom: 1px solid #ffe0a3;
  text-align: center;
}

.state-banner.ended {
  background: #f4f5f7;
  color: #5a6472;
  border-bottom-color: #e3e6eb;
}

.state-banner b { font-weight: 600; }
