* { box-sizing: border-box; margin: 0; padding: 0; }
/* 关键：让 hidden 属性真正生效（否则 .overlay 的 display:flex 会盖掉它，导致弹窗关不掉） */
[hidden] { display: none !important; }
body {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: #f3f5f9; color: #1f2937; min-height: 100vh;
}
.topbar {
  background: linear-gradient(135deg, #3b5bdb, #4f46e5);
  color: #fff; padding: 18px 26px; box-shadow: 0 2px 10px rgba(0,0,0,.15);
}
.brand { font-size: 24px; font-weight: 700; letter-spacing: .5px; }
.sub { opacity: .85; font-size: 13px; margin-top: 4px; }
.wrap { max-width: 1080px; margin: 22px auto; padding: 0 16px; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stat {
  background: #fff; border-radius: 12px; padding: 16px; text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,.06); border-top: 4px solid #4f46e5;
}
.stat.ok { border-top-color: #12b886; } .stat.out { border-top-color: #fa5252; } .stat.new { border-top-color: #fd7e14; }
.stat.overdue { border-top-color: #e8590c; }
.stat .num { font-size: 30px; font-weight: 700; }
.stat .label { color: #6b7280; font-size: 13px; margin-top: 4px; }

.panel { background: #fff; border-radius: 12px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,.06); }
.toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; padding: 9px 12px; border: 1px solid #d1d5db; border-radius: 8px; }
.btn {
  border: none; border-radius: 8px; padding: 9px 16px; cursor: pointer; font-size: 14px;
  background: #eef0f4; color: #374151; transition: filter .15s;
}
.btn:hover { filter: brightness(.96); }
.btn.primary { background: #4f46e5; color: #fff; }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 6px; }
.btn.ok { background: #d3f9d8; color: #087f5b; }
.btn.borrow { background: #fff3bf; color: #9a6700; }
.btn.danger { background: #ffe3e3; color: #c92a2a; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid #eef0f4; font-size: 14px; }
th { color: #6b7280; font-weight: 600; background: #fafbfc; }
tr:hover td { background: #f8f9fc; }
.badge { padding: 3px 10px; border-radius: 999px; font-size: 12px; }
.badge.in { background: #d3f9d8; color: #087f5b; }
.badge.out { background: #ffe3e3; color: #c92a2a; }
.empty { text-align: center; color: #9aa0a6; padding: 26px 0; }

.overlay {
  position: fixed; inset: 0; background: rgba(15,23,42,.45);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal {
  background: #fff; width: min(420px, 92vw); border-radius: 14px; padding: 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
.modal h3 { margin-bottom: 14px; }
.modal label { display: block; margin: 10px 0 4px; font-size: 13px; color: #4b5563; }
.modal label .tip { color: #868e96; font-size: 12px; margin-left: 6px; font-weight: 400; }
.modal input { width: 100%; padding: 9px 11px; border: 1px solid #d1d5db; border-radius: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 10px;
  font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.25); z-index: 99;
}
/* ---- 顶栏布局（原内联样式，CSP style-src 'self' 不允许内联 style，改 class）---- */
.topbar-row { display: flex; justify-content: space-between; align-items: center; }
#userbar { display: flex; align-items: center; gap: 10px; }
#userLabel { opacity: .9; }
.btn.logout { border: 1px solid rgba(255,255,255,.4); background: transparent; color: #fff; }
/* ---- 表格操作列与逾期高亮 ---- */
td.actions { white-space: nowrap; }
.due-overdue { color: #c92a2a; font-weight: 600; }
/* ---- 登录页 ---- */
.login-wrap { max-width: 420px; margin: 60px auto; }
.mode-title { margin-bottom: 8px; }
.cap-row { display: flex; gap: 8px; align-items: center; }
.cap-row input { flex: 1; }
.capimg { height: 40px; border-radius: 8px; cursor: pointer; background: #eef; }
.msg-box { padding: 8px 0; }
/* ---- 用户管理弹窗 ---- */
.modal-wide { width: min(1040px, 97vw); }
.usertbl { width: 100%; border-collapse: collapse; margin-top: 8px; }
.usertbl th, .usertbl td { text-align: left; padding: 9px 8px; border-bottom: 1px solid #eef0f4; font-size: 14px; }
.usertbl th { color: #6b7280; font-weight: 600; background: #fafbfc; }
.usertbl .perm-cell { text-align: center; }
.usertbl input[type="checkbox"] { width: 18px; height: 18px; accent-color: #4f46e5; cursor: pointer; }
.usertbl .muted { color: #9aa0a6; font-size: 13px; }
.badge.admin { background: #dbe4ff; color: #364fc7; }
.badge.cat { background: #e7f5ff; color: #1971c2; font-weight: 500; }
.sub-tip { font-size: 12px; color: #868e96; font-weight: 400; margin-left: 8px; }
/* ---- 汇总行 & 只读 ---- */
.sumline { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: #f1f3f9; color: #4b5563; font-size: 13px; }
.sumline::before { content: "📊 "; }
input[readonly] { background: #f1f3f5; color: #495057; cursor: default; }
.muted { color: #9aa0a6; }
/* ---- 库存/借出人/明细 ---- */
.stock-sub { font-size: 12px; color: #868e96; margin-top: 3px; }
td.borrower-cell { white-space: nowrap; }
.linkbtn {
  border: none; background: transparent; color: #4f46e5; cursor: pointer;
  padding: 0; font-size: 13px; text-decoration: underline dotted;
}
.linkbtn:hover { color: #364fc7; }
.hint { color: #868e96; font-size: 12px; margin: 2px 0 8px; }
.modal-detail { width: min(680px, 94vw); }
.emptycell { text-align: center; padding: 16px 0; }
.retn { width: 64px; padding: 4px 6px; border: 1px solid #d1d5db; border-radius: 6px; font-size: 13px; }
/* ---- 逾期警告 & 可点击统计卡 ---- */
.warn-chip {
  border: 1px solid #ffc9c9; background: #fff5f5; color: #c92a2a;
  border-radius: 999px; padding: 4px 12px; font-size: 13px; font-weight: 600;
  cursor: pointer; animation: warnblink 1.2s infinite alternate;
}
.warn-chip:hover { background: #ffe3e3; }
@keyframes warnblink { from { box-shadow: 0 0 0 rgba(201,42,42,0); } to { box-shadow: 0 0 0 3px rgba(201,42,42,.25); } }
#statOverdueCard.clickable { cursor: pointer; transition: box-shadow .15s; }
#statOverdueCard.clickable:hover { box-shadow: 0 2px 10px rgba(201,42,42,.35); }
#statOverdueCard.clickable::after { content: "查看 ▸"; display: block; font-size: 12px; color: #c92a2a; margin-top: 4px; }
/* ---- Excel 导入 ---- */
.import-result { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: #f4f6fb; font-size: 13px; max-height: 220px; overflow: auto; }
.import-result .err { color: #c92a2a; }
.import-result .errlist { margin: 6px 0 0 18px; color: #c92a2a; }
.modal .field input[type="file"] { padding: 8px; border: 1px dashed #c1c9e0; border-radius: 8px; background: #fafbff; margin-top: 4px; }
/* ================= 登录页美化 ================= */
.login-body {
  background: linear-gradient(135deg, #eef1fb 0%, #dbe4ff 55%, #c8d3f5 100%);
  min-height: 100vh;
}
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  width: min(400px, 94vw); background: #fff; border-radius: 18px;
  box-shadow: 0 18px 50px rgba(30, 50, 120, .18);
  padding: 34px 36px 24px;
}
.login-brand { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.login-logo { font-size: 42px; line-height: 1; }
.login-brand h1 { font-size: 21px; margin: 0; color: #1f2937; letter-spacing: .5px; }
.login-sub { margin: 2px 0 0; font-size: 12px; color: #868e96; }
.login-modetitle { font-size: 15px; color: #4f46e5; margin: 18px 0 6px; font-weight: 600; }
.login-form .field { display: block; margin: 12px 0 0; }
.login-form .field-label { display: block; font-size: 13px; color: #4b5563; margin-bottom: 6px; }
.login-form input { width: 100%; padding: 10px 12px; border: 1px solid #d1d5db; border-radius: 9px; font-size: 14px; transition: border-color .15s, box-shadow .15s; background: #fff; }
.login-form input:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 3px rgba(79,70,229,.15); }
.login-form .cap-row { display: flex; gap: 10px; align-items: center; }
.login-form .cap-row input { flex: 1; }
.login-form .capimg { height: 42px; border-radius: 9px; cursor: pointer; background: #eef2ff; border: 1px solid #e5e9f5; }
.login-submit { width: 100%; margin-top: 22px; padding: 11px; font-size: 15px; letter-spacing: 4px; border-radius: 9px; }
.login-switch { width: 100%; margin-top: 8px; background: transparent; border: none; color: #4f46e5; font-size: 13px; cursor: pointer; padding: 6px; }
.login-switch:hover { text-decoration: underline; }
.login-msg { text-align: center; font-size: 13px; min-height: 18px; margin-top: 10px; color: #9aa0a6; }
.login-foot { text-align: center; font-size: 12px; color: #adb5bd; margin-top: 14px; }
/* ---- 分页条 ---- */
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 12px; }
.pager-label { font-size: 13px; color: #6b7280; }
.pager button:disabled { opacity: .45; cursor: default; }
@media (max-width: 700px) { .stats { grid-template-columns: repeat(2,1fr); } }

/* 登录页面板切换 / 账号设置（邮箱功能） */
.login-tools { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; gap: 8px; }
.login-link { color: #1a73e8; cursor: pointer; font-size: 13px; text-decoration: none; background: none; border: none; padding: 0; }
.login-link:hover { text-decoration: underline; }
.login-form .hint { font-size: 12px; color: #9aa0a6; margin: 0 0 10px; line-height: 1.5; }
.account-email { word-break: break-all; }
