:root {
  --primary: #6b2fb9;
  --primary-dark: #4b1f86;
  --border: #d7d7d7;
  --text: #222;
  --muted: #666;
  --panel: rgba(255, 255, 255, 0.94);
  --danger: #c62828;
  --success: #1b7f3b;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--text);
  font-family: "Microsoft YaHei", Arial, sans-serif;
  background: #f2f2f2;
  min-height: 100vh;
}
body.gate-bg {
  background: url('../img/gate.jpg') center/cover fixed no-repeat, #f2f2f2;
}
body.air-bg {
  background: linear-gradient(rgba(25,18,45,.34), rgba(25,18,45,.44)), url('../img/air-view.jpg') center/cover fixed no-repeat, #62458c;
}
a { color: var(--primary-dark); text-decoration: none; }
a:hover { color: var(--primary); text-decoration: underline; }
.header {
  height: 74px;
  background: rgba(255,255,255,.97);
  border-bottom: 3px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 32px;
  box-shadow: 0 2px 10px rgba(0,0,0,.08);
}
.logo {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-dark);
  white-space: nowrap;
  cursor: pointer;
}
.search-bar {
  flex: 1;
  display: flex;
  justify-content: center;
  max-width: 780px;
  margin: 0 auto;
}
.search-bar input {
  width: 78%;
  height: 40px;
  border: 2px solid var(--primary);
  border-right: 0;
  padding: 0 14px;
  font-size: 15px;
  outline: none;
  background: #fff;
}
.search-bar button {
  width: 58px;
  height: 40px;
  border: 0;
  background: var(--primary);
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}
.user-area {
  min-width: 230px;
  text-align: right;
  font-size: 14px;
}
.user-area a, .user-area button {
  margin-left: 10px;
}
.main-wrap {
  width: calc(100% - 64px);
  max-width: 1360px;
  margin: 26px auto;
  display: grid;
  grid-template-columns: 245px 1fr;
  gap: 18px;
}
.side-panel, .content-panel, .card, .admin-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 2px 10px rgba(0,0,0,.06);
}
.side-panel { padding: 14px 16px 22px; }
.side-title {
  border-bottom: 2px solid var(--primary);
  padding-bottom: 10px;
  font-weight: 700;
  color: var(--primary-dark);
}
.filter-list { list-style: none; margin: 12px 0 0; padding: 0; }
.filter-list li {
  padding: 7px 0;
  border-bottom: 1px dashed #ddd;
  color: #333;
  font-size: 14px;
}
.filter-list input { margin-right: 8px; }
.content-panel { padding: 16px; overflow-x: auto; }
.table-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 12px;
}
table.cnki-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 14px;
}
.cnki-table th {
  background: #f4edf9;
  color: #333;
  border: 1px solid var(--border);
  height: 42px;
  font-weight: 700;
  white-space: nowrap;
}
.cnki-table td {
  border: 1px solid var(--border);
  padding: 10px 8px;
  text-align: center;
  vertical-align: middle;
}
.cnki-table tr:hover td { background: #fbf7ff; }
.cnki-table .name-cell { text-align: left; }
.btn {
  display: inline-block;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  padding: 7px 13px;
  border-radius: 2px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}
.btn:hover { background: var(--primary-dark); color: #fff; text-decoration: none; }
.btn.secondary { background: #fff; color: var(--primary-dark); }
.btn.secondary:hover { background: #f3eafa; }
.btn.danger { border-color: var(--danger); background: var(--danger); }
.btn.success { border-color: var(--success); background: var(--success); }
.btn.mini { padding: 5px 9px; font-size: 12px; }
.btn.disabled, .btn:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.pagination {
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.page-item {
  min-width: 34px;
  height: 32px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
}
.page-item.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-item:disabled { color: #aaa; background: #eee; cursor: not-allowed; }
.empty-tip { text-align: center; color: var(--muted); padding: 36px 0; }
.auth-box {
  width: 410px;
  margin: 8vh auto;
  background: rgba(255,255,255,.95);
  border-radius: 6px;
  padding: 32px 36px;
  box-shadow: 0 8px 28px rgba(0,0,0,.25);
}
.auth-box h1 { margin: 0 0 24px; color: var(--primary-dark); text-align: center; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; margin-bottom: 7px; color: #333; }
.form-row input, .form-row select, .form-row textarea {
  width: 100%;
  height: 38px;
  border: 1px solid #bbb;
  padding: 0 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}
.form-row textarea { height: 72px; padding-top: 8px; resize: vertical; }
.form-row input:focus, .form-row select:focus, .form-row textarea:focus { border-color: var(--primary); }
.captcha-line { display: flex; gap: 10px; align-items: center; }
.captcha-line input { flex: 1; }
.captcha-canvas { border: 1px solid #bbb; background: #fff; cursor: pointer; }
.auth-actions { margin-top: 20px; }
.auth-actions .btn { width: 100%; height: 40px; }
.auth-footer { text-align: center; margin-top: 16px; color: #555; }
.top-nav {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  background: rgba(255,255,255,.96);
  border-bottom: 3px solid var(--primary);
}
.container { width: calc(100% - 64px); max-width: 1240px; margin: 24px auto; }
.card { padding: 18px; margin-bottom: 18px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar input, .toolbar select { height: 34px; border: 1px solid #bbb; padding: 0 8px; }
.modal-mask {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 50;
  align-items: center;
  justify-content: center;
}
.modal {
  width: 460px;
  max-width: calc(100% - 30px);
  background: #fff;
  border-radius: 5px;
  padding: 22px;
  box-shadow: 0 8px 26px rgba(0,0,0,.26);
}
.modal h3 { margin-top: 0; color: var(--primary-dark); }
.modal-actions { text-align: right; margin-top: 18px; }
.admin-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 15px; }
.tab-btn { background: #fff; color: var(--primary-dark); }
.tab-btn.active { background: var(--primary); color: #fff; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.badge { padding: 3px 8px; border-radius: 12px; background: #eee; font-size: 12px; }
.badge.admin { color: #fff; background: var(--primary); }
.badge.disabled { color: #fff; background: #999; }
@media (max-width: 850px) {
  .header { height: auto; padding: 14px; flex-wrap: wrap; }
  .search-bar { order: 3; width: 100%; }
  .user-area { min-width: auto; flex: 1; }
  .main-wrap { grid-template-columns: 1fr; width: calc(100% - 24px); }
  .container { width: calc(100% - 24px); }
  .auth-box { width: calc(100% - 28px); }
}

/* 管理员后台：用户管理表格与顶部模块拉开距离，并让账号数据区域更居中 */
.admin-panel {
  padding: 28px 32px 34px;
}
.admin-tabs {
  margin-bottom: 30px;
}
#userSection .cnki-table th,
#userSection .cnki-table td {
  height: 56px;
  text-align: center;
  vertical-align: middle;
}
#userSection .cnki-table td {
  padding-top: 16px;
  padding-bottom: 16px;
}
#userSection .pagination {
  margin-top: 20px;
}


/* 登录注册页：密码小眼睛切换 */
.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.password-wrap input {
  padding-right: 46px;
}
.eye-btn {
  position: absolute;
  right: 8px;
  width: 30px;
  height: 30px;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 17px;
  line-height: 30px;
}
.eye-btn:hover {
  transform: scale(1.08);
}

/* 个人中心：仅本人可见的个人资料与寝室信息模块 */
.profile-card {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 34px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(2px);
}
.profile-title {
  border-bottom: 2px solid var(--primary);
  margin-bottom: 24px;
  padding-bottom: 14px;
}
.profile-title h2 {
  margin: 0 0 8px;
  color: var(--primary-dark);
}
.profile-title p {
  margin: 0;
  color: var(--muted);
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 28px;
}
.profile-section {
  border: 1px solid var(--border);
  background: rgba(255,255,255,.78);
  padding: 20px;
}
.profile-section h3 {
  margin: 0 0 16px;
  color: var(--primary-dark);
}
.profile-actions {
  margin-top: 24px;
  text-align: center;
}
.profile-actions .btn {
  min-width: 140px;
  margin: 0 6px;
}
@media (max-width: 850px) {
  .profile-grid {
    grid-template-columns: 1fr;
  }
}

/* 首页筛选目录：父级宿舍 + 子级寝室序号 */
.filter-parent-item {
  padding-bottom: 8px;
}
.filter-children {
  list-style: none;
  margin: 6px 0 0 24px;
  padding: 0 0 0 10px;
  border-left: 2px solid rgba(107,47,185,.25);
}
.filter-children li {
  padding: 5px 0;
  border-bottom: 0;
  color: #555;
  font-size: 13px;
}
.filter-children li::before {
  content: '└';
  color: var(--primary);
  margin-right: 6px;
}

/* 首页筛选目录：文件夹树展开/收起样式 */
.filter-parent-item {
  position: relative;
  padding: 7px 0 7px 0;
}
.tree-toggle,
.tree-toggle-placeholder {
  display: inline-flex;
  width: 20px;
  height: 20px;
  margin-right: 2px;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  color: #333;
  font-size: 22px;
  font-weight: 700;
  cursor: pointer;
  vertical-align: middle;
}
.tree-toggle:hover {
  color: var(--primary);
  background: rgba(107,47,185,.08);
}
.tree-parent-label {
  cursor: pointer;
  vertical-align: middle;
}
.folder-icon,
.file-icon {
  display: inline-block;
  width: 22px;
  margin: 0 3px 0 6px;
}
.filter-children.collapsed {
  display: none;
}
.filter-parent-item.expanded > .tree-parent-label {
  color: var(--primary-dark);
  font-weight: 600;
}
.filter-children {
  margin-top: 7px;
  margin-left: 28px;
}
.filter-children li::before {
  content: '';
  margin: 0;
}

/* 筛选目录：去除文件夹图片图标，仅保留展开箭头 */
.folder-icon,
.file-icon {
  display: none !important;
}
.tree-parent-label input,
.filter-children input {
  margin-right: 8px;
}

/* 首页筛选目录：三级树，宿舍类别 > 宿舍名称 > 寝室序号 */
.filter-list .tree-item {
  list-style: none;
  border-bottom: 1px dashed #ddd;
  padding: 7px 0;
}
.filter-level {
  list-style: none;
  margin: 7px 0 0 26px;
  padding: 0 0 0 10px;
  border-left: 2px solid rgba(107,47,185,.22);
}
.filter-level.collapsed {
  display: none;
}
.filter-level-2 > .tree-item,
.filter-level-3 > .tree-item {
  border-bottom: 0;
  padding: 5px 0;
}
.filter-level-2 label {
  color: #333;
}
.filter-level-3 label {
  color: #555;
  font-size: 13px;
}
.tree-empty {
  list-style: none;
  color: #888;
  font-size: 13px;
  padding: 6px 0;
}

/* ============================================
   手机端响应式适配（≤768px）
   ============================================ */
@media (max-width: 768px) {
  /* 顶部导航：堆叠 */
  .header {
    padding: 10px 12px;
    gap: 10px;
  }
  .logo { font-size: 18px; line-height: 1.2; }
  .search-bar {
    width: 100%;
    max-width: none;
    order: 3;
  }
  .search-bar input { width: 100%; height: 36px; font-size: 14px; }
  .search-bar button { width: 46px; height: 36px; font-size: 16px; }
  .user-area {
    min-width: auto;
    flex: 1;
    text-align: right;
    font-size: 13px;
  }
  .user-area a, .user-area button { margin-left: 6px; font-size: 12px; }

  /* 主区域：单列 */
  .main-wrap {
    grid-template-columns: 1fr;
    width: calc(100% - 16px);
    margin: 12px auto;
    gap: 10px;
  }
  .side-panel { padding: 10px 12px 14px; }
  .content-panel { padding: 10px; }

  /* 首页寝室列表表格：手机变卡片 */
  .cnki-table thead { display: none; }
  .cnki-table, .cnki-table tbody, .cnki-table tr, .cnki-table td {
    display: block;
    width: 100%;
    box-sizing: border-box;
  }
  .cnki-table tr {
    margin-bottom: 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    padding: 6px 4px;
  }
  .cnki-table td {
    border: 0;
    border-bottom: 1px dashed #eee;
    text-align: left;
    padding: 8px 12px;
    font-size: 13px;
    position: relative;
    padding-left: 100px;
    min-height: 36px;
  }
  .cnki-table td:last-child { border-bottom: 0; }
  .cnki-table td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    top: 8px;
    width: 84px;
    color: var(--primary-dark);
    font-weight: 600;
    font-size: 13px;
  }
  .cnki-table td.name-cell { padding-left: 100px; }
  .cnki-table tr:hover td { background: transparent; }
  .cnki-table tr td.empty-tip {
    padding-left: 12px;
    text-align: center;
  }
  .cnki-table tr td.empty-tip::before { content: ''; }

  /* 分页 */
  .pagination { gap: 4px; }
  .page-item { min-width: 30px; height: 28px; font-size: 12px; }

  /* 登录注册卡片 */
  .auth-box {
    width: calc(100% - 24px);
    margin: 30px auto;
    padding: 22px 18px;
  }
  .auth-box h1 { font-size: 22px; margin-bottom: 16px; }

  /* 表单输入 */
  .form-row input, .form-row select, .form-row textarea {
    height: 40px;
    font-size: 15px;
  }
  .captcha-canvas { width: 100px; height: 38px; }

  /* 个人中心 */
  .profile-card { padding: 16px 14px; }
  .profile-grid { grid-template-columns: 1fr; gap: 16px; }
  .profile-section { padding: 14px; }
  .profile-actions .btn { min-width: 110px; margin: 4px; }

  /* 管理员后台 */
  .admin-panel { padding: 14px 12px; }
  .admin-tabs { gap: 6px; margin-bottom: 14px; }
  .admin-tabs .btn { padding: 6px 10px; font-size: 12px; }

  /* 模态框 */
  .modal { width: calc(100% - 24px); max-width: none; padding: 20px 18px; }

  /* 按钮 */
  .btn { padding: 7px 12px; font-size: 13px; }
  .btn.mini { padding: 5px 8px; font-size: 12px; }

  /* 筛选树：缩进减小 */
  .filter-level { margin-left: 16px; padding-left: 8px; }
  .filter-level-3 label { font-size: 12px; }
}

@media (max-width: 420px) {
  .logo { font-size: 16px; }
  .cnki-table td { padding-left: 90px; font-size: 12px; }
  .cnki-table td::before { width: 78px; font-size: 12px; }
}

/* 底部版权栏 */
.site-footer {
  position: relative;
  margin-top: 30px;
  padding: 18px 14px;
  text-align: center;
  font-size: 13px;
  color: #fff;
  background: rgba(75, 31, 134, 0.55);
  letter-spacing: 1px;
  backdrop-filter: blur(2px);
}
.site-footer a { color: #ffd9ff; }
@media (max-width: 768px) {
  .site-footer { font-size: 12px; padding: 14px 10px; }
}
