/* ============ 设计令牌（对齐「入校登记」系统：靛蓝-紫渐变风） ============ */
:root {
  --bg: #fafbff;            /* 页面底色 */
  --surface: #ffffff;       /* 卡片 */
  --border: #e2e5ef;
  --primary: #4f6ef7;       /* 靛蓝主色 */
  --primary-dark: #3b5bd9;
  --primary-soft: #eaf0ff;  /* 主色浅底 */
  --topbar: linear-gradient(135deg, #4f6ef7, #7b4ff7); /* 渐变顶栏 */
  --topbar-solid: #4f6ef7;  /* 顶栏纯色（用于文字/图标取色） */
  --text: #1f2333;
  --text-2: #6b7191;
  --ok: #22a96c;
  --warn: #d66a28;
  --danger: #f5544f;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 35, 51, .06);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== 顶栏：常用网站式导航（logo + 标题 + 横排菜单 + 用户区） ===== */
.topbar {
  background: var(--topbar); color: #fff;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 52px;
  box-shadow: 0 1px 4px rgba(0,0,0,.15);
  position: sticky; top: 0; z-index: 50;
}
.topbar .brand {
  font-size: 16px; font-weight: 600; letter-spacing: .5px;
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
}
.topbar .brand .logo {
  width: 30px; height: 30px; border-radius: 7px; flex: none;
  background: #fff; color: var(--topbar-solid);
  font-size: 16px; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.topbar .brand .topbar-badge {
  width: 28px; height: 28px; border-radius: 6px; flex: none;
  background: #fff; padding: 2px; object-fit: contain;
}
.topbar .brand .sub {
  font-size: 12px; font-weight: 400; opacity: .72; letter-spacing: 0;
  border-left: 1px solid rgba(255,255,255,.28); padding-left: 10px; margin-left: 2px;
}
/* 横排导航菜单 */
.topbar .nav { display: flex; align-items: center; gap: 4px; height: 100%; margin-left: 28px; }
.topbar .nav a {
  color: rgba(255,255,255,.78); text-decoration: none; font-size: 14px;
  padding: 0 14px; height: 100%; line-height: 52px; display: inline-block;
  transition: background .15s, color .15s;
}
.topbar .nav a:hover { color: #fff; background: rgba(255,255,255,.10); }
.topbar .nav a.active {
  color: #fff; font-weight: 600;
  background: rgba(255,255,255,.14);
  box-shadow: inset 0 -3px 0 var(--primary-soft);
}
.topbar .user { display: flex; align-items: center; gap: 12px; font-size: 13px; }
.topbar .user .uname { opacity: .85; }
.btn-link {
  background: transparent; border: 1px solid rgba(255,255,255,.45);
  color: #fff; padding: 4px 14px; border-radius: 999px; cursor: pointer;
  font-size: 13px; text-decoration: none; transition: background .15s;
}
.btn-link:hover { background: rgba(255,255,255,.15); }

/* 容器、卡片 */
.container { max-width: 1180px; margin: 24px auto 60px; padding: 0 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  margin-bottom: 16px; box-shadow: var(--shadow);
}
.card h2 {
  font-size: 15px; font-weight: 600; margin: 0 0 14px; color: var(--text);
  display: flex; align-items: center; gap: 8px;
}
.card h2::before {
  content: ''; width: 4px; height: 15px; border-radius: 2px;
  background: var(--primary); flex: none;
}
.card h3 { font-size: 14px; margin: 18px 0 10px; color: #3a3f55; }

/* 表单 */
.row { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: #5a6180; }
label.block { margin-top: 14px; }
input, select, textarea {
  padding: 8px 10px; border: 1px solid #d6dce8; border-radius: 6px;
  font-size: 14px; font-family: inherit; background: #fff; outline: none;
  min-width: 130px; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,110,247,.15);
}
input[readonly] { background: #f2f4fa; color: var(--text-2); }
textarea { width: 100%; resize: vertical; }

.grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px; margin-top: 12px;
}

/* 按钮 */
.btn {
  padding: 8px 16px; border: 1px solid #d6dce8; background: #fff;
  color: #3a3f55; border-radius: 6px; cursor: pointer; font-size: 14px;
  transition: background .15s, border-color .15s, box-shadow .15s;
}
.btn:hover { background: #f6f8ff; border-color: var(--primary); color: var(--primary-dark); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.btn.primary {
  background: var(--primary); border-color: var(--primary); color: #fff;
}
.btn.primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.actions { margin-top: 18px; display: flex; gap: 10px; }

/* 提示 */
.tip { margin-top: 12px; font-size: 13px; color: var(--text-2); min-height: 18px; }
.tip.error { color: var(--danger); }
.tip.success { color: var(--ok); }
.tip.warn { color: var(--warn); }

/* 统计卡片：浅底 + 类型色左边条 */
.stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px; margin-bottom: 16px;
}
.stat {
  background: #f8faff; border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: 8px; padding: 12px 14px;
}
.stat .label { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }
.stat .value { font-size: 22px; font-weight: 600; color: var(--text);
  font-variant-numeric: tabular-nums; }
.stat.danger { border-left-color: var(--danger); }
.stat.danger .value { color: var(--danger); }
.stat.warn   { border-left-color: var(--warn); }
.stat.warn .value { color: var(--warn); }
.stat.ok     { border-left-color: var(--ok); }
.stat.ok .value { color: var(--ok); }

/* 表格 */
.table-wrap { overflow-x: auto; margin-top: 12px; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: 13px; white-space: nowrap; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
th { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
/* 全校汇总表头排序 */
th.sortable { cursor: pointer; user-select: none; -webkit-user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--primary); }
th.sort-active { color: var(--primary); }
th .sort-ind { display: inline-block; width: 12px; margin-left: 3px; font-size: 9px; line-height: 1; vertical-align: middle; }
tbody tr:hover { background: #f6f8ff; }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.num { text-align: right; }
td.center, th.center { text-align: center; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; line-height: 18px; white-space: nowrap;
}
.badge.pending   { background: #fff6f6; color: #c0392b; }
.badge.submitted { background: var(--primary-soft); color: var(--primary-dark); }
.badge.modified  { background: #f2f5ff; color: #4f6ef7; }
.badge.late      { background: #fdf0e7; color: #c2611f; }

.link { color: var(--primary); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ===== 登录：左右分栏（左品牌区 / 右表单区） ===== */
.login-wrap { min-height: 100vh; display: flex; }
.login-side {
  flex: 1.1; background: var(--topbar); color: #fff;
  display: flex; flex-direction: column; justify-content: center;
  padding: 48px 8%; position: relative; overflow: hidden;
}
.login-side::before {
  content: ''; position: absolute; right: -70px; top: -70px;
  width: 260px; height: 260px; border-radius: 50%;
  background: rgba(255,255,255,.06);
}
.login-side::after {
  content: ''; position: absolute; left: -50px; bottom: -80px;
  width: 220px; height: 220px; border-radius: 50%;
  background: rgba(255,255,255,.05);
}
.login-side .glyph { font-size: 44px; margin-bottom: 12px; }
.login-side .school-badge {
  width: 96px; height: 96px; flex: none;
  object-fit: contain; margin-bottom: 18px; position: relative;
  filter: drop-shadow(0 6px 14px rgba(31, 35, 51, .28));
}
.login-side h1 { font-size: 26px; line-height: 1.35; margin: 0; position: relative; }
.login-side p { font-size: 14px; opacity: .75; margin-top: 10px; position: relative; }
.login-main {
  flex: 1; background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}
.login-box { width: 340px; }
.login-box h2 { font-size: 20px; margin: 0 0 4px; }
.login-box .sub { color: var(--text-2); font-size: 13px; margin-bottom: 26px; }
.login-box label { margin-bottom: 16px; }
.login-box input { width: 100%; }
.login-box .btn { width: 100%; padding: 10px; margin-top: 6px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 30, 40, .55);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.modal {
  background: #fff; width: 540px; max-width: 92vw; max-height: 86vh;
  overflow-y: auto; border-radius: 12px; padding: 20px 22px;
  box-shadow: 0 16px 40px rgba(0,0,0,.25);
  border-top: 4px solid var(--primary);
}
.modal h3 { margin: 0 0 16px; font-size: 16px; }
.modal .close-row { text-align: right; margin-top: 18px; display: flex; gap: 10px; justify-content: flex-end; }
.modal .field { display: flex; justify-content: space-between; padding: 6px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px; }
.modal .field:last-child { border-bottom: none; }
.modal .field .k { color: var(--text-2); }
.modal .field .v { color: var(--text); font-weight: 500; }

/* Toast */
.toast {
  position: fixed; right: 20px; bottom: 20px; z-index: 999;
  background: #1f2333; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: toastIn .2s ease;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--primary); }
@keyframes toastIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* 代改弹窗：学生行（移动端换行，避免姓名被挤压成折叠） */
.e-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 5px 10px; border-bottom: 1px solid var(--line, #f0f0f0); }
.e-row .e-id { min-width: 26px; color: #9aa0b8; }
.e-row .e-name { flex: 1; }
.e-row .e-type { max-width: 110px; }
.e-row .e-remark { max-width: 140px; }

/* ================= 移动端自适应 ================= */
@media (max-width: 640px) {
  body { font-size: 13px; }

  .topbar { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 6px 10px; }
  .topbar .brand { font-size: 15px; }
  .topbar .brand .sub { display: none; }
  .topbar .nav { margin-left: 0; height: auto; width: 100%; order: 3; }
  .topbar .nav a { line-height: 34px; padding: 0 12px; font-size: 13px; }
  .topbar .nav a.active { box-shadow: inset 0 -2px 0 var(--primary-soft); }
  .topbar .user { margin-left: auto; }

  .container { margin: 12px auto 40px; padding: 0 10px; }
  .card { padding: 14px 12px; border-radius: 8px; margin-bottom: 12px; }
  .card h2 { font-size: 14px; }

  .row { gap: 10px; }
  .row label { flex: 1 1 45%; min-width: 0; }
  .row label input, .row label select { width: 100%; min-width: 0; }
  .row > .btn { flex: 1 1 100%; padding: 10px; }
  /* 起止日期：纵向堆叠各占整行——微信内置浏览器 date 输入有固有最小宽、
     不响应收缩，横向并排会相互溢出重叠，堆叠可彻底消除 */
  .row label.date-field { flex: 1 1 100%; min-width: 0; max-width: 100%; }
  .row label input[type="date"] { width: 100%; min-width: 0; max-width: 100%; box-sizing: border-box; }
  .row label select { min-width: 0; }

  .grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  input, select, textarea { min-width: 0; font-size: 16px; /* 16px 防 iOS 聚焦放大 */ }

  .table-wrap { margin-top: 8px; }
  table { font-size: 12px; }
  th, td { padding: 7px 8px; }

  .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .stat { padding: 8px 10px; }
  .stat .value { font-size: 17px; }

  /* 代改弹窗学生行：姓名整行，类型/备注各占半行，杜绝姓名被压成折叠 */
  .e-row .e-name { flex: 1 1 100%; }
  .e-row .e-type, .e-row .e-remark { flex: 1 1 45%; max-width: none; }

  .login-wrap { flex-direction: column; }
  .login-side { padding: 40px 28px 32px; min-height: 30vh; }
  .login-side .school-badge { width: 72px; height: 72px; margin-bottom: 14px; }
  .login-side h1 { font-size: 20px; }
  .login-side::before, .login-side::after { display: none; }
  .login-main { padding: 32px 20px; }
  .login-box { width: 100%; max-width: 340px; }

  .modal-mask { align-items: flex-end; }
  .modal {
    width: 100vw; max-width: 100vw; max-height: 88vh;
    border-radius: 12px 12px 0 0;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .toast {
    left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom));
    text-align: center;
  }

  .actions { flex-direction: column; }
  .actions .btn { width: 100%; padding: 11px; }
}
