/* =========================================================
   智慧图书馆 · 设计系统
   ========================================================= */
:root {
  --brand: #4f46e5;
  --brand-2: #7c3aed;
  --brand-soft: #eef2ff;
  --ink: #0f172a;
  --ink-2: #334155;
  --ink-3: #64748b;
  --ink-4: #94a3b8;
  --line: #e6e8ef;
  --bg: #f6f7fb;
  --card: #ffffff;
  --green: #10b981;
  --red: #ef4444;
  --amber: #f59e0b;
  --cyan: #06b6d4;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .04), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow: 0 4px 16px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
  --shadow-lg: 0 18px 40px -12px rgba(15, 23, 42, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
img { max-width: 100%; display: block; }

::selection { background: #c7d2fe; }

/* 滚动条 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d3d7e0; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #bcc2cf; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 通用布局 ---------------- */
.wrap { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.wrap-sm { max-width: 880px; margin: 0 auto; padding: 0 24px; }

.row { display: flex; align-items: center; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.grow { flex: 1; min-width: 0; }
.wrap-text { overflow-wrap: anywhere; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }

.mt-1 { margin-top: 6px; } .mt-2 { margin-top: 12px; } .mt-3 { margin-top: 18px; }
.mt-4 { margin-top: 24px; } .mt-6 { margin-top: 36px; }
.mb-2 { margin-bottom: 12px; } .mb-3 { margin-bottom: 18px; }
.muted { color: var(--ink-3); }
.tiny { font-size: 12px; }
.small { font-size: 13px; }
.bold { font-weight: 650; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------------- 卡片 ---------------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 22px; border-bottom: 1px solid var(--line);
}
.card-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.card-sub { font-size: 12px; color: var(--ink-4); font-weight: 500; }
.card-body { padding: 20px 22px; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 13px;
  cursor: pointer; transition: .18s ease; white-space: nowrap;
}
.btn:hover { background: #4338ca; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: #f8fafc; border-color: #d7dbe5; color: var(--ink); }
.btn-soft { background: var(--brand-soft); color: var(--brand); }
.btn-soft:hover { background: #e0e7ff; }
.btn-danger { background: #fee2e2; color: #b91c1c; }
.btn-danger:hover { background: #fecaca; }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12px; border-radius: 8px; }
.btn-xs { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 7px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; pointer-events: none; }

/* ---------------- 表单 ---------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.input, .select, .textarea {
  width: 100%; height: 40px; padding: 0 12px;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  outline: none; transition: .16s;
}
.textarea { height: auto; padding: 10px 12px; min-height: 96px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: #a5b4fc; box-shadow: 0 0 0 3px rgba(99, 102, 241, .13);
}
.input::placeholder, .textarea::placeholder { color: #b6bcc9; }
.select { appearance: none; background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8.5 1.8 4.3l.9-.9L6 6.7l3.3-3.3.9.9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }
.form-hint { font-size: 11.5px; color: var(--ink-4); }
.form-err { font-size: 12px; color: var(--red); }

/* 搜索框 */
.search {
  display: flex; align-items: center; gap: 8px; height: 42px; padding: 0 14px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
}
.search input { border: none; outline: none; flex: 1; background: transparent; font-size: 14px; }
.search svg { flex: none; color: var(--ink-4); }

/* ---------------- 徽章 ---------------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 23px; padding: 0 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  background: #f1f5f9; color: var(--ink-3);
}
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: #b91c1c; }
.badge-amber { background: #fef3c7; color: #b45309; }
.badge-cyan { background: #cffafe; color: #0e7490; }
.badge-violet { background: #f3e8ff; color: #7e22ce; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------------- 表格 ---------------- */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 12px; font-weight: 650; color: var(--ink-4);
  padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
  letter-spacing: .02em;
}
.table td { padding: 13px 14px; border-bottom: 1px solid #f1f3f8; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafbfe; }
.table .t-right { text-align: right; }

/* ---------------- 书封（程序化生成） ---------------- */
.cover {
  position: relative; border-radius: 6px 10px 10px 6px; overflow: hidden;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px 12px 12px 18px; color: #fff; flex: none;
  box-shadow: 0 6px 16px -6px rgba(15, 23, 42, .5), inset 0 0 0 1px rgba(255,255,255,.14);
}
.cover::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 7px;
  background: rgba(0, 0, 0, .22); box-shadow: inset -1px 0 0 rgba(255,255,255,.16);
}
.cover::after {
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 80% 0%, rgba(255,255,255,.26), transparent 60%);
  pointer-events: none;
}
.cover-t {
  font-weight: 700; line-height: 1.3; letter-spacing: -.01em;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .18); position: relative;
}
.cover-a { font-size: 11px; opacity: .82; position: relative; }
.cover-sm { width: 46px; height: 62px; padding: 8px 7px 7px 12px; border-radius: 4px 7px 7px 4px; }
.cover-sm .cover-t { font-size: 8.5px; -webkit-line-clamp: 4; }
.cover-md { width: 78px; height: 106px; }
.cover-md .cover-t { font-size: 11px; }
.cover-lg { width: 150px; height: 205px; padding: 18px 16px 14px 22px; }
.cover-lg .cover-t { font-size: 16px; }
.cover-xl { width: 190px; height: 260px; padding: 22px 20px 18px 26px; border-radius: 8px 14px 14px 8px; }
.cover-xl .cover-t { font-size: 20px; -webkit-line-clamp: 4; }

/* ---------------- 顶部导航（读者端） ---------------- */
.nav {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .86); backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-inner { display: flex; align-items: center; gap: 22px; height: 62px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 16px; letter-spacing: -.02em; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff;
  box-shadow: 0 4px 12px -3px rgba(79, 70, 229, .6);
}
.nav-links { display: flex; align-items: center; gap: 4px; }
.nav-link {
  padding: 7px 12px; border-radius: 9px; font-size: 13.5px; font-weight: 600;
  color: var(--ink-3); transition: .15s;
}
.nav-link:hover { background: #f1f3f9; color: var(--ink); }
.nav-link.active { background: var(--brand-soft); color: var(--brand); }

.avatar {
  width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #a855f7); color: #fff;
  font-weight: 700; font-size: 14px; flex: none;
}
.avatar-lg { width: 64px; height: 64px; font-size: 24px; border-radius: 18px; }

/* ---------------- 后台侧栏 ---------------- */
.shell { display: flex; min-height: 100vh; }
.side {
  width: 232px; flex: none; position: sticky; top: 0; height: 100vh;
  background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; padding: 18px 14px;
}
.side .brand { color: #fff; padding: 6px 8px 18px; }
.side-group { font-size: 11px; font-weight: 700; color: #64748b; padding: 14px 10px 6px; letter-spacing: .08em; }
.side-link {
  display: flex; align-items: center; gap: 10px; padding: 9px 11px; border-radius: 9px;
  font-size: 13.5px; font-weight: 600; color: #a9b6c9; transition: .15s; margin-bottom: 2px;
}
.side-link:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.side-link.active { background: linear-gradient(100deg, #4f46e5, #7c3aed); color: #fff; box-shadow: 0 6px 18px -8px rgba(99, 102, 241, .9); }
.side-link svg { flex: none; opacity: .95; }
.side-foot { margin-top: auto; padding: 12px 8px 4px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 64px; display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
.page { padding: 24px 28px 60px; }
.page-title { font-size: 20px; font-weight: 750; letter-spacing: -.02em; }
.page-desc { font-size: 13px; color: var(--ink-3); margin-top: 2px; }

/* ---------------- 指标卡 ---------------- */
.stat {
  position: relative; overflow: hidden;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow-sm);
  transition: .2s;
}
.stat:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-label { font-size: 12.5px; color: var(--ink-3); font-weight: 600; }
.stat-value { font-size: 27px; font-weight: 780; letter-spacing: -.03em; margin-top: 6px; line-height: 1.1; }
.stat-foot { font-size: 11.5px; color: var(--ink-4); margin-top: 6px; display: flex; align-items: center; gap: 5px; }
.stat-ico {
  position: absolute; right: 16px; top: 16px; width: 34px; height: 34px; border-radius: 10px;
  display: grid; place-items: center;
}
.up { color: var(--green); font-weight: 700; }
.down { color: var(--red); font-weight: 700; }

/* ---------------- 闪光提示 ---------------- */
.flash-wrap { position: fixed; top: 74px; right: 24px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.flash {
  display: flex; align-items: flex-start; gap: 10px; min-width: 260px; max-width: 400px;
  padding: 12px 16px; border-radius: 12px; background: #fff; box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--green); font-size: 13.5px; font-weight: 550;
  animation: slideIn .3s cubic-bezier(.2,.9,.3,1);
}
.flash.err { border-left-color: var(--red); }
.flash .x { margin-left: auto; color: var(--ink-4); cursor: pointer; }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

/* ---------------- 空状态 ---------------- */
.empty { padding: 54px 20px; text-align: center; color: var(--ink-4); }
.empty-ico {
  width: 56px; height: 56px; margin: 0 auto 14px; border-radius: 16px;
  background: #f1f3f9; display: grid; place-items: center; color: #b9c0cd;
}
.empty-t { font-weight: 650; color: var(--ink-3); font-size: 14px; }

/* ---------------- 分页 ---------------- */
.pager { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.pager a, .pager span {
  min-width: 34px; height: 34px; padding: 0 10px; border-radius: 9px;
  display: grid; place-items: center; font-size: 13px; font-weight: 600;
  background: #fff; border: 1px solid var(--line); color: var(--ink-2);
}
.pager a:hover { border-color: #c7d2fe; color: var(--brand); }
.pager .active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .disabled { opacity: .45; }

/* ---------------- 进度条 ---------------- */
.bar { height: 7px; border-radius: 999px; background: #eef0f6; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); }

/* ---------------- 图表容器 ---------------- */
.chart-box { position: relative; width: 100%; }
.chart-h-260 { height: 260px; }
.chart-h-220 { height: 220px; }
.chart-h-300 { height: 300px; }
.chart-h-180 { height: 180px; }

/* ---------------- 排行榜 ---------------- */
.rank { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px dashed #eef0f6; }
.rank:last-child { border-bottom: none; }
.rank-no {
  width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center;
  font-size: 11.5px; font-weight: 750; background: #f1f5f9; color: var(--ink-3); flex: none;
}
.rank-no.top1 { background: linear-gradient(135deg, #fbbf24, #f59e0b); color: #fff; }
.rank-no.top2 { background: linear-gradient(135deg, #cbd5e1, #94a3b8); color: #fff; }
.rank-no.top3 { background: linear-gradient(135deg, #fdba74, #f97316); color: #fff; }

/* ---------------- 提示块 ---------------- */
.note {
  display: flex; gap: 10px; padding: 13px 16px; border-radius: 12px;
  background: #f8faff; border: 1px solid #e0e7ff; font-size: 13px; color: #3730a3;
}
.note-amber { background: #fffbeb; border-color: #fde68a; color: #92400e; }

/* ---------------- 分段控件 ---------------- */
.seg { display: inline-flex; padding: 3px; background: #f1f3f9; border-radius: 10px; gap: 2px; }
.seg a {
  padding: 6px 13px; border-radius: 8px; font-size: 12.5px; font-weight: 650; color: var(--ink-3);
  transition: .15s;
}
.seg a.active { background: #fff; color: var(--brand); box-shadow: var(--shadow-sm); }

/* ---------------- 摄像头 ---------------- */
.cam {
  position: relative; border-radius: 18px; overflow: hidden; background: #0b1120;
  aspect-ratio: 4/3; display: grid; place-items: center;
}
.cam video, .cam canvas { width: 100%; height: 100%; object-fit: cover; }
.cam video { transform: scaleX(-1); }
.cam-overlay { position: absolute; inset: 0; pointer-events: none; }
.cam-frame {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 58%; aspect-ratio: 3/4; border-radius: 50% 50% 46% 46% / 42% 42% 58% 58%;
  border: 2.5px dashed rgba(255, 255, 255, .55);
}
.cam-frame.ok { border-color: #34d399; border-style: solid; box-shadow: 0 0 0 4px rgba(52, 211, 153, .18); }
.cam-hint {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  padding: 6px 14px; border-radius: 999px; background: rgba(2, 6, 23, .62);
  color: #e2e8f0; font-size: 12.5px; font-weight: 600; backdrop-filter: blur(6px);
  white-space: nowrap;
}
.scan-line {
  position: absolute; left: 8%; right: 8%; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, transparent, #38bdf8, transparent);
  animation: scan 2.1s ease-in-out infinite;
  box-shadow: 0 0 14px 2px rgba(56, 189, 248, .6);
}
@keyframes scan { 0%,100% { top: 16%; opacity: .2; } 50% { top: 80%; opacity: 1; } }

/* ---------------- 动画 ---------------- */
.fade-up { animation: fadeUp .45s cubic-bezier(.2,.9,.3,1) both; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.pulse-ring { animation: pulseRing 1.8s ease-out infinite; }
@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .45); }
  70% { box-shadow: 0 0 0 16px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
  .side { display: none; }
  .page { padding: 18px 16px 50px; }
  .topbar { padding: 0 16px; }
  .wrap { padding: 0 16px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .nav-links { display: none; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
}
