:root {
  --primary: #009fe9;        /* 华誉认证品牌蓝（导航/按钮/主色）*/
  --primary-light: #5fc0ff;  /* 科技蓝浅变体（hover / 强调）*/
  --primary-dark: #0072b1;   /* 深蓝（渐变 / 文字强调）*/
  --accent: #00a0e9;         /* 品牌蓝强调色 */
  --bg: #f4f8fb;
  --card: #ffffff;
  --text: #333333;
  --muted: #999999;
  --border: #e4ecf2;
  --success: #27ae60;
  --danger: #e05b5b;
  --radius: 10px;
  --shadow: 0 8px 30px rgba(0, 90, 140, 0.10);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

a {
  color: var(--primary-light);
  text-decoration: none;
}

/* ===== 登录页 ===== */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-light));
  padding: 20px;
}

.login-box {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  padding: 40px 36px;
}

.login-box .brand {
  text-align: center;
  margin-bottom: 28px;
}

.login-box .brand .logo {
  width: 80px;
  height: 80px;
  margin: 0 auto 12px;
  display: block;
  object-fit: contain;
}

.login-box .brand h1 {
  font-size: 20px;
  color: var(--primary);
}

.login-box .brand p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ===== 表单 ===== */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  font-weight: 600;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  background: #fbfcfe;
  transition: border 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 159, 233, 0.15);
  background: #fff;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--primary);
  color: #fff;
}

.btn:hover {
  background: var(--primary-dark);
}

.btn-block {
  width: 100%;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--primary);
  color: var(--primary);
}

.btn-outline:hover {
  background: var(--primary);
  color: #fff;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-danger {
  background: var(--danger);
}

.btn-danger:hover {
  background: #c94848;
}

.btn-success {
  background: var(--success);
}

/* ===== 顶部导航 ===== */
.topbar {
  height: 62px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar .title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
}

.topbar .user-info {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
}

.topbar .user-info .divider {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.25);
}

.topbar .user-info a {
  color: #fff;
  opacity: 0.9;
}

.topbar .user-info a:hover {
  opacity: 1;
  text-decoration: underline;
}

/* ===== 布局 ===== */
.layout {
  display: flex;
  min-height: calc(100vh - 62px);
}

.sidebar {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 18px 0;
}

.sidebar .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  border-left: 3px solid transparent;
}

.sidebar .nav-item:hover {
  background: var(--bg);
}

.sidebar .nav-item.active {
  background: rgba(0, 159, 233, 0.10);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.content {
  flex: 1;
  padding: 24px 30px;
  overflow: auto;
}

.page-head {
  margin-bottom: 20px;
}

.page-head h2 {
  font-size: 20px;
  color: var(--primary);
}

.page-head p {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}

.card h3 {
  font-size: 16px;
  color: var(--text);
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

/* ===== 证书卡片网格 ===== */
.cert-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 20px;
}

.cert-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}

.cert-card .thumb {
  height: 150px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  position: relative;
}

.cert-card .thumb .badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: #ffffff;
  color: var(--primary-dark);
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.cert-card .body {
  padding: 16px;
  flex: 1;
}

.cert-card .body h4 {
  font-size: 15px;
  color: var(--text);
  margin-bottom: 8px;
}

.cert-card .meta {
  font-size: 12.5px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cert-card .actions {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}

.cert-card .actions .btn {
  flex: 1;
}

/* ===== 表格 ===== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

thead th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: #fafbfe;
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: rgba(39, 174, 96, 0.12);
  color: var(--success);
}

/* ===== 工具栏 ===== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar .search {
  display: flex;
  gap: 8px;
}

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(0, 45, 75, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-mask.open {
  display: flex;
}

.modal {
  background: var(--card);
  border-radius: 14px;
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal .modal-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
}

.modal .modal-head h3 {
  font-size: 16px;
  color: var(--primary);
}

.modal .close-x {
  cursor: pointer;
  font-size: 22px;
  color: var(--muted);
  border: none;
  background: none;
  line-height: 1;
}

.modal .modal-body {
  padding: 0;
  flex: 1;
  overflow: auto;
}

.modal .modal-body iframe {
  width: 100%;
  height: 70vh;
  border: none;
  display: block;
}

/* 预览弹窗：高度随窗口自适应（区别于表单弹窗）*/
.modal.modal-preview {
  height: min(92vh, 1000px);
  max-height: none;
}

.modal-preview .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0;
  display: flex;
}

.modal-preview .modal-body iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  flex: 1;
}

/* PDF.js canvas 预览容器（全环境统一）：纵向 flex，内容区不滚动 */
.modal .modal-body .pdf-view {
  display: none;
  flex: 1;
  height: 100%;
  overflow: hidden;
  background: #525659;
  flex-direction: column;
  box-sizing: border-box;
}

/* 单页展示区：居中、裁剪溢出，配合 contain 缩放自然无滚动条 */
.pdf-stage {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 16px;
}

.pdf-stage canvas {
  display: block;
  background: #fff;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
  max-width: 100%;
  max-height: 100%;
}

/* 底部翻页条 */
.pdf-pager {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px;
  background: #3a3f42;
  color: #fff;
  font-size: 13px;
}

.pdf-pager .pdf-pageinfo {
  min-width: 56px;
  text-align: center;
}

.pdf-pager .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pdf-loading,
.pdf-error {
  color: #fff;
  text-align: center;
  padding: 40px 20px;
  font-size: 14px;
}

.modal .modal-body.pad {
  padding: 22px;
}

/* ===== 上传区 ===== */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s;
  background: #fbfcfe;
}

.dropzone:hover {
  border-color: var(--primary);
  background: rgba(0, 159, 233, 0.05);
}

.dropzone .icon {
  font-size: 40px;
  margin-bottom: 8px;
}

/* ===== 表单网格 ===== */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.hint {
  font-size: 12px;
  color: var(--muted);
  margin-top: 6px;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

/* ===== 列表页：分页条固定于页面底部 ===== */
body.list-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

body.list-page > .content {
  flex: 1 0 auto;
  width: 100%;
}

/* 页面底部预留分页条高度，避免内容被遮挡 */
.content {
  padding-bottom: 104px;
}

@media (max-width: 720px) {
  .sidebar {
    display: none;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* ---------- 用户创建成功：账号密码展示 ---------- */
.cred-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px dashed var(--primary-light);
  border-radius: 8px;
  background: #f2fafe;
  margin-bottom: 10px;
}

.cred-row .cred-label {
  flex: none;
  width: 64px;
  color: var(--muted);
  font-size: 13px;
}

.cred-row .cred-value {
  flex: 1;
  font-size: 16px;
  color: var(--primary-dark);
  letter-spacing: 1px;
  word-break: break-all;
}

/* ---------- 上传证书：所属单位可搜索下拉 ---------- */
.owner-select {
  position: relative;
}

.owner-dropdown {
  display: none;
  position: absolute;
  z-index: 60;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.owner-dropdown.open {
  display: block;
}

.owner-item {
  padding: 10px 14px;
  font-size: 14px;
  cursor: pointer;
}

.owner-item .u {
  color: var(--muted);
  font-size: 12px;
  margin-left: 4px;
}

.owner-item:hover {
  background: #f2fafe;
  color: var(--primary-dark);
}

.owner-item.active {
  background: var(--primary);
  color: #fff;
}

.owner-item.active .u {
  color: rgba(255, 255, 255, 0.85);
}

.owner-empty {
  color: var(--muted);
  cursor: default;
}

/* ---------- 所属单位选择弹窗：固定高度防跳动 ---------- */
.owner-table-wrap {
  height: 400px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.owner-table-wrap table {
  margin: 0;
}

.owner-table-wrap th {
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 1;
}

.owner-table-wrap td {
  background: #fff;
}

/* ---------- 通用分页条 ---------- */
.pager-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.05);
  backdrop-filter: blur(6px);
}

.pager-bar .page-info {
  color: var(--muted);
  font-size: 13px;
}

/* 后台：分页条避开左侧导航栏 */
.sidebar ~ .content .pager-bar {
  left: 220px;
}

@media (max-width: 720px) {
  .sidebar ~ .content .pager-bar {
    left: 0;
  }
}
