/* 品牌色变量：拿到学校品牌色后，仅需修改这一组值即可全局替换 */
:root {
  --brand: #1f5fbf;
  --brand-dark: #16498f;
  --brand-light: #eaf2ff;
  --accent: #f0a732;
  --ink: #1d2733;
  --ink-2: #5b6875;
  --ink-3: #8b97a3;
  --line: #e6ebf1;
  --bg: #f5f7fa;
  --card: #ffffff;
  --ok: #1f9d6b;
  --ok-bg: #e9f7f1;
  --warn: #d9822b;
  --warn-bg: #fdf2e6;
  --danger: #d64545;
  --danger-bg: #fdecec;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(23, 43, 77, .07);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
button { font-family: inherit; }

/* ---------- 登录 ---------- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 12% -10%, #dbe9ff 0%, transparent 60%),
    radial-gradient(700px 500px at 100% 100%, #fdeed3 0%, transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.brand-mark {
  width: 46px; height: 46px; flex: none;
  border-radius: 50%;
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(23, 43, 77, .16);
}
.brand-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand-name { font-size: 15px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }
.login-title { font-size: 24px; margin: 0 0 6px; }
.login-desc { font-size: 13px; color: var(--ink-2); margin: 0 0 26px; line-height: 1.6; }

.field-label { display: block; font-size: 13px; font-weight: 600; margin: 16px 0 8px; }
.field-input {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fff; font-size: 14px; color: var(--ink);
  outline: none; transition: border-color .18s, box-shadow .18s;
}
.field-input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-light); }
.field-input::placeholder { color: var(--ink-3); }
.field-error { color: var(--danger); font-size: 12px; min-height: 16px; margin-top: 4px; }
.code-row { display: flex; gap: 10px; }
.code-row .field-input { flex: 1; }
.code-row .btn { flex: none; height: 44px; padding: 0 14px; font-size: 13px; }

.btn {
  border: 1px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
  transition: all .18s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-ghost { background: #fff; color: var(--brand); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { filter: brightness(.94); }
.btn-soft { background: var(--brand-light); color: var(--brand); }
.btn-soft:hover:not(:disabled) { filter: brightness(.97); }
.btn-block { width: 100%; height: 46px; margin-top: 22px; font-size: 15px; }
.btn-sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.form-msg { margin-top: 12px; font-size: 13px; color: var(--danger); min-height: 18px; }
.hint { font-size: 12px; color: var(--ink-3); margin: 6px 0 0; }

.auth-tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 12px; margin-bottom: 22px; }
.auth-tab {
  flex: 1; text-align: center; padding: 10px; border-radius: 9px;
  font-size: 14px; font-weight: 600; cursor: pointer; color: var(--ink-2);
  transition: all .18s;
}
.auth-tab:hover { color: var(--brand); }
.auth-tab.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(23,43,77,.08); }

.role-options { display: grid; gap: 10px; }
.role-option {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; cursor: pointer; transition: all .18s;
}
.role-option:hover { border-color: var(--brand); }
.role-option.selected { border-color: var(--brand); background: var(--brand-light); }
.role-option input { display: none; }
.role-icon { font-size: 22px; }
.role-text b { display: block; font-size: 14px; }
.role-text small { display: block; font-size: 12px; color: var(--ink-2); margin-top: 2px; }
.code-box { margin-top: 14px; }

/* ---------- 主体布局 ---------- */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px; border-bottom: 1px solid var(--line);
}
.nav { flex: 1; padding: 14px 12px; overflow-y: auto; }
.nav-group-title { font-size: 11px; color: var(--ink-3); padding: 12px 12px 6px; letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; margin: 2px 0;
  border-radius: 10px; cursor: pointer;
  font-size: 14px; color: var(--ink-2);
  transition: all .15s;
}
.nav-item:hover { background: var(--bg); color: var(--ink); }
.nav-item.active { background: var(--brand-light); color: var(--brand); font-weight: 600; }
.nav-ico { font-size: 17px; width: 20px; text-align: center; }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--line); }
.side-user { font-size: 13px; margin-bottom: 10px; }
.side-user b { display: block; font-size: 14px; }
.side-user span { color: var(--ink-3); }

.main { flex: 1; min-width: 0; }
.topbar {
  height: 78px; background: #fff;
  border-bottom: 1px solid var(--line);
  padding: 0 30px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 20px; margin: 0; }
.page-sub { font-size: 12px; color: var(--ink-3); margin: 3px 0 0; }
.role-badge {
  font-size: 12px; font-weight: 600;
  padding: 6px 12px; border-radius: 20px;
  background: var(--brand-light); color: var(--brand);
}
.content { padding: 26px 30px 50px; max-width: 1440px; }

/* ---------- 通用组件 ---------- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.stat-card .label { font-size: 13px; color: var(--ink-2); }
.stat-card .value { font-size: 30px; font-weight: 700; margin: 8px 0 4px; line-height: 1; }
.stat-card .foot { font-size: 12px; color: var(--ink-3); }
.stat-card .ico { float: right; font-size: 26px; opacity: .85; }

.panel {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; margin-bottom: 20px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.panel-title { font-size: 16px; font-weight: 700; margin: 0; }
.panel-tools { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-input { height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; font-size: 13px; width: 220px; outline: none; }
.search-input:focus { border-color: var(--brand); }

.tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; }
.tab {
  padding: 7px 14px; border-radius: 20px; cursor: pointer;
  font-size: 13px; border: 1px solid var(--line); color: var(--ink-2);
  background: #fff; transition: all .15s;
}
.tab:hover { border-color: var(--brand); }
.tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--ink-2); font-weight: 600; background: #fafbfc; }
tbody tr:hover { background: #fafcff; }
tbody tr:last-child td { border-bottom: none; }
.title-cell { font-weight: 600; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.sub-cell { font-size: 11px; color: var(--ink-3); margin-top: 3px; }

.chip { display: inline-block; padding: 3px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.chip-ok { background: var(--ok-bg); color: var(--ok); }
.chip-warn { background: var(--warn-bg); color: var(--warn); }
.chip-danger { background: var(--danger-bg); color: var(--danger); }
.chip-info { background: var(--brand-light); color: var(--brand); }

.lang-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 6px; background: #f2f5f9; color: var(--ink-2); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.icon-btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  height: 30px; padding: 0 10px; border-radius: 8px; cursor: pointer; font-size: 12px;
  transition: all .15s;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.icon-btn.primary:hover:not(:disabled) { background: var(--brand-dark); color: #fff; }
.icon-btn:disabled { opacity: .5; cursor: not-allowed; }
.icon-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.empty { text-align: center; padding: 56px 20px; color: var(--ink-3); }
.empty .big { font-size: 42px; margin-bottom: 12px; }
.empty p { margin: 0 0 16px; font-size: 13px; }

/* 图书卡片 */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.book-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  transition: transform .15s, box-shadow .15s;
}
.book-card:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(23,43,77,.11); }
.book-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 10px; }
.book-title { font-size: 15px; font-weight: 700; line-height: 1.4; }
.book-author { font-size: 12px; color: var(--ink-2); margin-top: 5px; }
.book-meta { font-size: 12px; color: var(--ink-3); margin: 12px 0; display: grid; gap: 5px; }
.book-meta div { display: flex; justify-content: space-between; }
.book-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(16, 26, 40, .45);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal {
  width: 100%; max-width: 520px; background: #fff;
  border-radius: 18px; padding: 26px; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  max-height: 88vh; overflow-y: auto;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.modal-title { font-size: 18px; font-weight: 700; margin: 0; }
.modal-close { border: none; background: none; font-size: 22px; cursor: pointer; color: var(--ink-3); line-height: 1; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal-foot .btn { min-width: 92px; height: 40px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }

.toast {
  position: fixed; left: 50%; bottom: 36px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px;
  border-radius: 10px; font-size: 13px; z-index: 100;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.toast.ok { background: var(--ok); }
.toast.error { background: var(--danger); }

@media (max-width: 820px) {
  .sidebar { width: 68px; }
  .sidebar-brand > div:last-child, .nav-group-title, .nav-item span:not(.nav-ico), .side-user { display: none; }
  .nav-item { justify-content: center; }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
}
