:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e6e9f0;
  --border-strong: #d3d8e4;
  --text: #1f2733;
  --text-2: #5b6573;
  --text-3: #939aa8;
  --primary: #4f46e5;
  --primary-d: #4338ca;
  --primary-soft: #eef0fe;
  --teal: #0d9488;
  --teal-soft: #d9f3ef;
  --amber: #d97706;
  --amber-soft: #fdf0dc;
  --red: #dc2626;
  --red-soft: #fde8e8;
  --green: #16a34a;
  --green-soft: #e3f6ea;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.06), 0 1px 3px rgba(16,24,40,.08);
  --shadow-md: 0 4px 14px rgba(16,24,40,.10);
  --shadow-lg: 0 18px 48px rgba(16,24,40,.18);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --sidebar-w: 244px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, #1e1b4b 0%, #312e81 55%, #3730a3 100%);
  color: #dfe2f5;
  display: flex; flex-direction: column;
  padding: 18px 14px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 6px 8px 18px; }
.brand-logo {
  width: 40px; height: 40px; border-radius: 11px;
  background: linear-gradient(135deg, #818cf8, #c4b5fd);
  color: #1e1b4b; font-weight: 800; font-size: 20px;
  display: grid; place-items: center; box-shadow: 0 6px 16px rgba(129,140,248,.45);
}
.brand-title { font-weight: 700; font-size: 15px; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 11px; color: #b9bce8; margin-top: 1px; }
.nav { display: flex; flex-direction: column; gap: 4px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px; border-radius: 10px; cursor: pointer;
  color: #c7cae8; font-size: 13.5px; transition: all .15s ease; border: none; background: none; text-align: left; width: 100%;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(255,255,255,.16); color: #fff; font-weight: 600; box-shadow: inset 3px 0 0 #a5b4fc; }
.nav-item .ic { width: 18px; height: 18px; flex: 0 0 18px; opacity: .9; }
.nav-item .badge { margin-left: auto; background: #ef4444; color: #fff; font-size: 11px; padding: 1px 7px; border-radius: 999px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding-top: 14px; }
.env-pill { font-size: 11.5px; color: #c7f9d8; background: rgba(16,185,129,.18); padding: 5px 10px; border-radius: 999px; display: inline-block; }
.tip { font-size: 11px; color: #a9addd; margin-top: 9px; line-height: 1.5; }

/* ---------- Main ---------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 26px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.search-wrap { flex: 1; display: flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 11px; padding: 7px 10px 7px 12px; }
.search-wrap:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-wrap .ic { width: 17px; height: 17px; color: var(--text-3); }
.search-wrap input { flex: 1; border: none; background: none; outline: none; font-size: 13.5px; color: var(--text); }
.topbar-actions { display: flex; gap: 10px; }

.view { padding: 24px 26px 60px; flex: 1; }

/* ---------- Buttons ---------- */
.btn-primary, .btn-ghost, .btn-danger, .btn-soft {
  border: 1px solid transparent; border-radius: 9px; padding: 8px 14px;
  font-size: 13px; cursor: pointer; transition: all .15s ease; font-weight: 600;
}
.btn-primary { background: var(--primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-d); }
.btn-ghost { background: var(--surface-2); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-soft { background: var(--primary-soft); color: var(--primary-d); }
.btn-soft:hover { background: #e3e6fd; }
.btn-danger { background: var(--red-soft); color: var(--red); }
.btn-danger:hover { background: #fbdada; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }

/* ---------- Page head ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; gap: 16px; flex-wrap: wrap; }
.page-title { font-size: 19px; font-weight: 700; margin: 0; }
.page-sub { color: var(--text-3); font-size: 12.5px; margin-top: 3px; }
.page-actions { display: flex; gap: 9px; flex-wrap: wrap; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; gap: 16px; }
.cards-4 { grid-template-columns: repeat(4, 1fr); }
.cards-2 { grid-template-columns: repeat(2, 1fr); }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 18px; box-shadow: var(--shadow-sm);
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }
.stat-card { position: relative; overflow: hidden; }
.stat-card .label { color: var(--text-3); font-size: 12.5px; }
.stat-card .value { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: .5px; }
.stat-card .value.sm { font-size: 20px; }
.stat-card .accent { position: absolute; right: -18px; top: -18px; width: 76px; height: 76px; border-radius: 50%; opacity: .12; }
.stat-card.indigo .accent { background: var(--primary); }
.stat-card.teal .accent { background: var(--teal); }
.stat-card.amber .accent { background: var(--amber); }
.stat-card.red .accent { background: var(--red); }

/* ---------- Table ---------- */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); box-shadow: var(--shadow-sm); overflow: hidden; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl thead th { background: var(--surface-2); color: var(--text-2); font-weight: 600; text-align: left;
  padding: 11px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; position: sticky; top: 0; }
table.tbl tbody td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.tbl tbody tr:hover { background: #fafbff; }
table.tbl tbody tr:last-child td { border-bottom: none; }
.tbl .title-cell { font-weight: 600; color: var(--text); }
.tbl .sub { color: var(--text-3); font-size: 11.5px; }
.row-actions { display: flex; gap: 6px; }

/* ---------- Badges ---------- */
.badge-cat { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: var(--primary-soft); color: var(--primary-d); }
.badge-st { padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.badge-ok { background: var(--green-soft); color: var(--green); }
.badge-warn { background: var(--amber-soft); color: var(--amber); }
.badge-bad { background: var(--red-soft); color: var(--red); }
.chip { display: inline-block; padding: 1px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11.5px; color: var(--text-2); margin: 1px 3px 1px 0; }
.tags { max-width: 220px; }
.tag-att { color: var(--teal); }

/* ---------- Filter bar ---------- */
.filterbar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md);
  padding: 14px 16px; box-shadow: var(--shadow-sm); margin-bottom: 16px; display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field label { font-size: 11.5px; color: var(--text-3); font-weight: 600; }
.field input, .field select, .field textarea {
  border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; font-size: 13px; outline: none;
  background: var(--surface); color: var(--text); font-family: inherit; min-width: 140px;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field.grow { flex: 1; }
.field.grow input { min-width: 0; width: 100%; }
.fb-actions { display: flex; gap: 8px; margin-left: auto; }

/* ---------- Modal ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(17,24,39,.5); backdrop-filter: blur(2px);
  display: grid; place-items: center; z-index: 60; animation: fade .15s ease; }
.modal { background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  width: min(720px, 94vw); max-height: 90vh; display: flex; flex-direction: column; animation: pop .18s ease; }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-head h2 { margin: 0; font-size: 16px; }
.modal-body { padding: 20px 22px; overflow: auto; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.x-btn { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--text-3); line-height: 1; }
.x-btn:hover { color: var(--text); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 16px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-hint { font-size: 11.5px; color: var(--text-3); margin-top: 4px; }
.suggest-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--text-2); }

/* ---------- Drawer ---------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(17,24,39,.45); z-index: 55; animation: fade .15s ease; }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(520px, 96vw); background: var(--surface);
  box-shadow: var(--shadow-lg); z-index: 56; display: flex; flex-direction: column; animation: slideIn .2s ease; }
.drawer-head { padding: 18px 22px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.drawer-body { padding: 20px 22px; overflow: auto; flex: 1; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin-bottom: 16px; }
.kv dt { color: var(--text-3); font-size: 12.5px; }
.kv dd { margin: 0; font-size: 13.5px; word-break: break-word; }
.summary-box { background: var(--primary-soft); border: 1px solid #dcdcfb; border-radius: var(--r-md); padding: 14px; font-size: 13px; white-space: pre-wrap; color: var(--text); }
.att-preview { background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--r-sm); padding: 12px; font-size: 12px; color: var(--text-2); max-height: 180px; overflow: auto; white-space: pre-wrap; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 16px; flex-wrap: wrap; }
.tab { padding: 9px 14px; border: none; background: none; cursor: pointer; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; font-weight: 600; }
.tab.active { color: var(--primary-d); border-bottom-color: var(--primary); }
.tab .cnt { background: var(--surface-2); border-radius: 999px; padding: 0 7px; font-size: 11px; margin-left: 5px; color: var(--text-3); }

/* ---------- Alerts ---------- */
.alert { border-radius: var(--r-md); padding: 12px 16px; font-size: 13px; margin-bottom: 14px; }
.alert-bad { background: var(--red-soft); color: #991b1b; border: 1px solid #f5c2c2; }
.alert-warn { background: var(--amber-soft); color: #92400e; border: 1px solid #f3d8a8; }
.alert-ok { background: var(--green-soft); color: #166534; border: 1px solid #bbe9c9; }

/* ---------- Bars / progress ---------- */
.bar-row { display: flex; align-items: center; gap: 10px; margin: 9px 0; font-size: 12.5px; }
.bar-row .name { width: 130px; color: var(--text-2); flex: 0 0 130px; }
.bar-track { flex: 1; height: 9px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); border-radius: 999px; }
.bar-fill.teal { background: linear-gradient(90deg, #0d9488, #2dd4bf); }
.bar-fill.amber { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar-fill.red { background: linear-gradient(90deg, #ef4444, #f87171); }
.bar-row .num { width: 46px; text-align: right; font-weight: 700; }

/* ---------- Empty ---------- */
.empty { text-align: center; padding: 50px 20px; color: var(--text-3); }
.empty .big { font-size: 38px; opacity: .5; }
.empty p { margin: 10px 0 0; }

/* ---------- Toast ---------- */
#toastRoot { position: fixed; right: 22px; bottom: 22px; z-index: 90; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1f2733; color: #fff; padding: 11px 16px; border-radius: 10px; box-shadow: var(--shadow-md); font-size: 13px; animation: slideUp .2s ease; max-width: 360px; }
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }

/* ---------- Misc ---------- */
.muted { color: var(--text-3); }
.mono { font-variant-numeric: tabular-nums; }
.link { color: var(--primary-d); cursor: pointer; text-decoration: none; }
.link:hover { text-decoration: underline; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }
.section-title { font-size: 14px; font-weight: 700; margin: 22px 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title .ic { width: 16px; height: 16px; color: var(--primary); }
.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 16px; align-items: start; }
.pub-group { border: 1px solid var(--border); border-radius: var(--r-md); margin-bottom: 12px; overflow: hidden; }
.pub-group .pg-head { background: var(--surface-2); padding: 9px 14px; font-weight: 700; font-size: 13px; display: flex; justify-content: space-between; }
.pub-group .pg-body { padding: 4px 0; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes slideIn { from { transform: translateX(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes slideUp { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

@media (max-width: 1080px) {
  .cards-4 { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .cards-2 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .form-grid { grid-template-columns: 1fr; }
  .cards-4 { grid-template-columns: 1fr; }
}

/* ---------- 用户框 ---------- */
.user-box { display: flex; align-items: center; gap: 8px; }
.user-box .ub-name { font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border); padding: 4px 10px; border-radius: 999px; }

/* ---------- 登录 ---------- */
.login-modal { width: min(420px, 94vw); }
.login-brand { text-align: center; color: var(--primary-d); font-weight: 700; font-size: 14px; margin-bottom: 16px; letter-spacing: .5px; }
#loginMask .modal-foot { padding: 14px 22px; }

/* ---------- 资格清单打印 ---------- */
.print-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 28px 34px; box-shadow: var(--shadow-sm); max-width: 900px; margin: 0 auto; }
.pq-head { text-align: center; border-bottom: 2px solid var(--text); padding-bottom: 12px; margin-bottom: 18px; }
.pq-title { font-size: 20px; font-weight: 800; letter-spacing: 1px; }
.pq-sub { font-size: 12px; color: var(--text-2); margin-top: 6px; }
.pq-sec { margin-bottom: 18px; }
.pq-sec h3 { font-size: 14.5px; font-weight: 700; margin: 0 0 8px; }
.pq-tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.pq-tbl td { border: 1px solid var(--border); padding: 8px 10px; vertical-align: top; }
.pq-check { width: 34px; text-align: center; font-size: 16px; color: var(--text-3); }
.pq-foot { margin-top: 22px; font-size: 13px; color: var(--text-2); line-height: 2.2; }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  #app { display: block; }
  body { background: #fff; }
  .view { padding: 0; }
  .print-doc { box-shadow: none; border: none; max-width: 100%; padding: 0; }
  .pq-tbl td { border-color: #999; }
}

/* ============ 独立登录窗口 ============ */
.login-screen { position: fixed; inset: 0; z-index: 9999; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 38%, #4f46e5 100%); }
.login-bg::before, .login-bg::after { content: ""; position: absolute; border-radius: 50%; filter: blur(8px); opacity: .55; }
.login-bg::before { width: 460px; height: 460px; left: -120px; top: -140px; background: radial-gradient(circle, rgba(99,102,241,.8), transparent 70%); }
.login-bg::after { width: 520px; height: 520px; right: -160px; bottom: -180px; background: radial-gradient(circle, rgba(14,165,233,.7), transparent 70%); }
.login-wrap { position: relative; z-index: 1; width: min(900px, 94vw); height: min(560px, 92vh); display: grid; grid-template-columns: 1fr 1fr; background: #fff; border-radius: 20px; overflow: hidden; box-shadow: 0 30px 80px rgba(15,23,42,.45); animation: loginIn .5s cubic-bezier(.16,.84,.44,1); }
@keyframes loginIn { from { opacity: 0; transform: translateY(18px) scale(.98); } to { opacity: 1; transform: none; } }
.login-aside { background: linear-gradient(160deg, #1e293b, #1e3a8a 60%, #2563eb); color: #fff; padding: 38px 34px; display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.la-logo { width: 56px; height: 56px; border-radius: 14px; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-size: 28px; font-weight: 800; backdrop-filter: blur(4px); }
.la-title { font-size: 28px; margin: 0; letter-spacing: 1px; }
.la-sub { margin: 0; opacity: .8; font-size: 14px; }
.la-points { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 10px; font-size: 13.5px; opacity: .92; }
.la-points li { padding-left: 4px; }
.la-foot { margin-top: auto; font-size: 12px; opacity: .65; }
.login-card { padding: 40px 38px; display: flex; flex-direction: column; justify-content: center; }
.lc-head { margin-bottom: 18px; }
.lc-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent, #2563eb); box-shadow: 0 0 0 5px rgba(37,99,235,.15); display: inline-block; margin-bottom: 10px; }
.lc-head h2 { margin: 0 0 4px; font-size: 22px; }
.lc-head p { margin: 0; color: var(--text-2); font-size: 13px; }
.login-card .field input { height: 42px; font-size: 14px; }
.login-go { height: 46px; font-size: 15px; letter-spacing: 4px; margin-top: 14px; }
.login-go:disabled { opacity: .6; cursor: not-allowed; }
.lc-tip { margin-top: 14px; font-size: 12px; color: var(--text-2); text-align: center; }
@media (max-width: 720px) {
  .login-wrap { grid-template-columns: 1fr; height: auto; }
  .login-aside { display: none; }
}

/* ============ 权限 / 用户管理 ============ */
.ub-role { font-size: 12px; background: var(--accent, #2563eb); color: #fff; padding: 2px 9px; border-radius: 999px; margin-left: 4px; }
.user-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; align-items: center; margin-bottom: 14px; padding: 14px; border: 1px solid var(--border, #e5e7eb); border-radius: 12px; background: var(--bg, #f8fafc); }
.user-form .inp { height: 38px; }
.perm-row { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 10px 16px; }
.chk { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; cursor: pointer; }
.user-list { margin-top: 4px; }
.user-list .grid { font-size: 13px; }
.user-list .badge-st { font-size: 11px; padding: 1px 7px; margin-right: 4px; }

/* ---------------- WPS 在线编辑弹窗 ---------------- */
.wps-mask { position: fixed; inset: 0; z-index: 10000; background: rgba(15,23,42,.55); display: flex; align-items: center; justify-content: center; padding: 18px; }
.wps-modal { width: min(1180px, 96vw); height: min(800px, 94vh); background: #fff; border-radius: var(--r-lg); overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); }
.wps-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.wps-title { font-weight: 700; font-size: 15px; color: var(--text); }
.wps-actions { display: flex; align-items: center; gap: 8px; }
.wps-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* ---------------- 出版社授权联动校验提示 ---------------- */
.pub-check { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.pub-check-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.pub-check-badge.ok { background: var(--green-soft); color: var(--green); }
.pub-check-badge.warn { background: var(--amber-soft); color: var(--amber); }
.pub-check-badge.bad { background: var(--red-soft); color: var(--red); }
.pub-check-msg { font-size: 12.5px; color: var(--text-2); }
