/**
 * 自定义样式层（叠加在 Tabler 之上）。
 * 引入顺序：tabler.min.css -> tabler-icons.min.css -> 本文件。
 *
 * 设计原则：页面外壳（侧边栏/顶栏/卡片/表格）使用原生 Tabler 结构与类名；
 * 业务页面中由 JS 模板字符串生成的旧类名（button.secondary / badge.green /
 * modal-mask 等）通过本文件映射到 Tabler 设计变量，无需改动业务 JS。
 */

/* ---------- 主题与旧变量映射 ---------- */
:root {
  --tblr-font-sans-serif: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;

  /* 主色调：靛蓝紫（覆盖 Tabler 默认蓝），营造更炫酷的科技感 */
  --brand: #6366f1;
  --brand-2: #8b5cf6;
  --brand-3: #4f46e5;
  --brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --brand-gradient-strong: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);
  --sidebar-gradient: linear-gradient(185deg, #1e1b4b 0%, #262056 55%, #2e1065 100%);

  /* 覆盖 Tabler RGB 主色变量，使所有 .btn-primary / .text-primary / .bg-primary 等联动 */
  --tblr-primary: #6366f1;
  --tblr-primary-rgb: 99, 102, 241;

  /* 旧代码（含 JS 内联样式）引用的变量 */
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --success: var(--tblr-success, #2fb344);
  --danger: var(--tblr-danger, #d63939);
  --warning: var(--tblr-warning, #f76707);
  --bg: #f4f5fb;
  --card-bg: var(--tblr-bg-surface, #ffffff);
  --border: var(--tblr-border-color, #e7e7f0);
  --text: var(--tblr-body-color, #1c223b);
  --text-muted: var(--tblr-secondary, #6b7192);
}

body {
  background: radial-gradient(1200px 600px at 100% -5%, rgba(139, 92, 246, .10), transparent 55%),
              radial-gradient(1000px 500px at -5% 0%, rgba(99, 102, 241, .10), transparent 50%),
              var(--bg);
}

/* Tabler 主按钮统一为品牌渐变 */
.btn-primary {
  background-image: var(--brand-gradient);
  border-color: transparent;
  box-shadow: 0 4px 12px rgba(99, 102, 241, .28);
}
.btn-primary:hover, .btn-primary:focus, .btn-primary:active {
  background-image: var(--brand-gradient-strong);
  border-color: transparent;
}

/* 品牌渐变头像/图标块（登录、验证页等的顶部标识） */
.avatar.bg-primary,
.avatar.bg-azure {
  background: var(--brand-gradient) !important;
  box-shadow: 0 8px 20px rgba(99, 102, 241, .35);
}

/* 独立页（登录/验证）柔和渐变背景 */
.page.page-center {
  background: radial-gradient(1000px 500px at 100% 0%, rgba(139, 92, 246, .12), transparent 55%),
              radial-gradient(900px 500px at 0% 100%, rgba(99, 102, 241, .12), transparent 55%),
              var(--bg);
}

.hidden {
  display: none !important;
}

/* ---------- 侧边栏：深色靛紫渐变 ---------- */
.navbar-vertical.navbar-expand-lg {
  background: var(--sidebar-gradient) !important;
  border-right: 0;
  box-shadow: 4px 0 24px rgba(30, 27, 75, .18);
}

.navbar-vertical .navbar-brand .avatar {
  background: var(--brand-gradient) !important;
  box-shadow: 0 4px 14px rgba(139, 92, 246, .45);
}

.navbar-vertical .nav-link {
  color: rgba(255, 255, 255, .72) !important;
  border-radius: 10px;
  margin: 2px .5rem;
  padding: .55rem .75rem;
  transition: all .18s ease;
}

.navbar-vertical .nav-link:hover {
  color: #fff !important;
  background: rgba(255, 255, 255, .08);
}

.navbar-vertical .nav-item.active .nav-link,
.navbar-vertical .nav-link.active {
  color: #fff !important;
  background: var(--brand-gradient);
  box-shadow: 0 6px 16px rgba(124, 58, 237, .45);
}

.navbar-vertical .nav-link-icon {
  color: inherit !important;
  opacity: .95;
}

/* ---------- 卡片 ---------- */
.card {
  padding: 1.25rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 1px 2px rgba(28, 34, 59, .04), 0 8px 24px rgba(28, 34, 59, .05);
}

.card h2, .card h3 {
  margin-top: 0;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.card-title-row h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

/* ---------- 首页统计卡片 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 1px 2px rgba(28, 34, 59, .04), 0 10px 26px rgba(28, 34, 59, .06);
  padding: 1.25rem 1.35rem;
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}

.stat-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--brand-gradient);
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 2px 4px rgba(28, 34, 59, .06), 0 18px 40px rgba(99, 102, 241, .16);
}

.stat-card .stat-label {
  color: var(--text-muted);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .03em;
  margin-bottom: .3rem;
}

.stat-card .stat-value {
  font-size: 1.9rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -.01em;
}

/* 渐变图标圆 */
.stat-card .stat-icon {
  float: right;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  font-size: 1.35rem;
  background: var(--brand-gradient);
  box-shadow: 0 6px 16px rgba(99, 102, 241, .35);
}

/* 每张卡不同色调，避免单调 */
.stat-card.tone-1 .stat-icon { background: linear-gradient(135deg, #6366f1, #8b5cf6); box-shadow: 0 6px 16px rgba(99,102,241,.35); }
.stat-card.tone-1::before { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-card.tone-2 .stat-icon { background: linear-gradient(135deg, #0ea5e9, #22d3ee); box-shadow: 0 6px 16px rgba(14,165,233,.35); }
.stat-card.tone-2::before { background: linear-gradient(135deg, #0ea5e9, #22d3ee); }
.stat-card.tone-3 .stat-icon { background: linear-gradient(135deg, #f59e0b, #f97316); box-shadow: 0 6px 16px rgba(245,158,11,.35); }
.stat-card.tone-3::before { background: linear-gradient(135deg, #f59e0b, #f97316); }
.stat-card.tone-4 .stat-icon { background: linear-gradient(135deg, #ec4899, #d946ef); box-shadow: 0 6px 16px rgba(236,72,153,.35); }
.stat-card.tone-4::before { background: linear-gradient(135deg, #ec4899, #d946ef); }
.stat-card.tone-5 .stat-icon { background: linear-gradient(135deg, #10b981, #34d399); box-shadow: 0 6px 16px rgba(16,185,129,.35); }
.stat-card.tone-5::before { background: linear-gradient(135deg, #10b981, #34d399); }

/* ---------- 首页：欢迎横幅 ---------- */
.hero-banner {
  position: relative;
  border-radius: 18px;
  padding: 1.75rem 2rem;
  margin-bottom: 1.25rem;
  color: #fff;
  background: var(--brand-gradient-strong);
  box-shadow: 0 18px 40px rgba(79, 70, 229, .3);
  overflow: hidden;
}

.hero-banner::after {
  content: "";
  position: absolute;
  right: -60px;
  top: -60px;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
  border-radius: 50%;
}

.hero-banner .hero-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 .35rem;
  letter-spacing: -.01em;
}

.hero-banner .hero-sub {
  font-size: .875rem;
  opacity: .9;
  margin: 0;
  max-width: 640px;
  line-height: 1.7;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  margin-top: 1rem;
}

.hero-badges span {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  font-size: .75rem;
  font-weight: 600;
  padding: .3rem .7rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, .16);
  backdrop-filter: blur(4px);
}

/* ---------- 首页：快捷入口 ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: .75rem;
}

.quick-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text);
  text-decoration: none;
  transition: all .18s ease;
}

.quick-item:hover {
  border-color: transparent;
  color: var(--brand-3);
  transform: translateY(-2px);
  box-shadow: 0 12px 26px rgba(99, 102, 241, .18);
}

.quick-item .qi-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 1.2rem;
  color: #fff;
  flex-shrink: 0;
  background: var(--brand-gradient);
}

.quick-item .qi-text { line-height: 1.3; }
.quick-item .qi-text .qi-title { font-weight: 600; font-size: .9rem; }
.quick-item .qi-text .qi-desc { font-size: .72rem; color: var(--text-muted); }

/* ---------- 首页：图表条形 ---------- */
.chart-bars {
  display: flex;
  flex-direction: column;
  gap: .85rem;
}

.chart-bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 48px;
  align-items: center;
  gap: .75rem;
  font-size: .8125rem;
}

.chart-bar-track {
  height: 12px;
  border-radius: 999px;
  background: rgba(99, 102, 241, .1);
  overflow: hidden;
}

.chart-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand-gradient);
  width: 0;
  transition: width .8s cubic-bezier(.2, .8, .2, 1);
}

.chart-bar-fill.c-green { background: linear-gradient(135deg, #10b981, #34d399); }
.chart-bar-fill.c-amber { background: linear-gradient(135deg, #f59e0b, #f97316); }
.chart-bar-fill.c-red   { background: linear-gradient(135deg, #f43f5e, #ec4899); }
.chart-bar-fill.c-gray  { background: linear-gradient(135deg, #94a3b8, #cbd5e1); }
.chart-bar-value { text-align: right; font-weight: 700; }

/* ---------- 表单（旧结构：.form-row / .form-group + 裸 input） ---------- */
.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: .875rem;
  margin-bottom: .75rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  flex: 1;
  min-width: 160px;
  margin-bottom: .5rem;
}

.form-group.narrow {
  max-width: 130px;
}

.form-group > label {
  font-size: .875rem;
  font-weight: 500;
  color: var(--text);
}

.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea {
  display: block;
  width: 100%;
  padding: .4375rem .75rem;
  font-size: .875rem;
  font-family: inherit;
  line-height: 1.4285714;
  color: var(--text);
  background: var(--tblr-bg-forms, #fff);
  border: 1px solid var(--border);
  border-radius: var(--tblr-border-radius, 4px);
  outline: 0;
  transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23667382' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpath d='M6 9l6 6l6 -6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right .55rem center;
  background-size: 16px;
  padding-right: 2rem;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #90b5e2;
  box-shadow: 0 0 0 .25rem rgba(32, 107, 196, .12);
}

.form-group input[type="file"] {
  padding: .3rem .5rem;
}

.form-group input[disabled],
.form-group select[disabled] {
  background: var(--bg);
  color: var(--text-muted);
}

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: .625rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.filter-bar .form-group {
  min-width: 140px;
  flex: 0 1 180px;
  margin-bottom: 0;
}

/* ---------- 按钮兼容层（无 .btn 的旧按钮 → Tabler 风格） ---------- */
button:not(.btn):not(.navbar-toggler) {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .375rem;
  padding: .4375rem .875rem;
  font-size: .875rem;
  font-weight: 500;
  font-family: inherit;
  line-height: 1.4285714;
  white-space: nowrap;
  color: #fff;
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--tblr-border-radius, 4px);
  cursor: pointer;
  user-select: none;
  transition: color .15s, background-color .15s, border-color .15s, box-shadow .15s;
}

button:not(.btn):not(.navbar-toggler):hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

button:not(.btn):disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

button.secondary:not(.btn) {
  color: var(--text);
  background: var(--card-bg);
  border-color: var(--border);
}

button.secondary:not(.btn):hover {
  color: var(--primary);
  background: var(--bg);
  border-color: #b9c3ce;
}

button.danger:not(.btn) {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

button.danger:not(.btn):hover {
  background: #bd2c2c;
  border-color: #bd2c2c;
}

button.ghost:not(.btn) {
  color: var(--text-muted);
  background: transparent;
  border-color: var(--border);
}

button.ghost:not(.btn):hover {
  color: var(--text);
  background: var(--bg);
}

button.small:not(.btn) {
  padding: .125rem .5rem;
  font-size: .75rem;
}

/* 少数使用 .btn small secondary 组合的元素（如上传照片 label） */
.btn.small {
  padding: .125rem .5rem;
  font-size: .75rem;
}

.btn.secondary {
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.btn.secondary:hover {
  color: var(--primary);
  background: var(--bg);
}

/* ---------- 表格 ---------- */
.table-actions {
  display: flex;
  gap: .375rem;
  flex-wrap: wrap;
}

.empty-row {
  text-align: center;
  color: var(--text-muted);
  padding: 2rem 0;
}

/* JS 注入的无类名表格（验证页明细等）基础样式 */
table:not([class]) {
  width: 100%;
  border-collapse: collapse;
}

table:not([class]) th,
table:not([class]) td {
  padding: .5rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: .8125rem;
}

table:not([class]) th {
  color: var(--text-muted);
  font-weight: 600;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: var(--bg);
}

table:not([class]) tbody tr:hover {
  background: var(--bg);
}

.verify-detail-table td {
  font-size: .8125rem;
  padding: .45rem .5rem;
}

/* ---------- 徽章颜色别名（旧 badge green/red/... 写法） ---------- */
.badge.green  { background: rgba(47, 179, 68, .12);  color: #2b8a3e; }
.badge.red    { background: rgba(214, 57, 57, .12);  color: #c92a2a; }
.badge.blue   { background: rgba(32, 107, 196, .12); color: var(--primary); }
.badge.yellow { background: rgba(245, 159, 0, .16);  color: #b25d00; }
.badge.gray   { background: rgba(102, 115, 130, .12); color: var(--text-muted); }

/* ---------- 提示条（showAlert 注入 .alert.success/... 及弹窗内提示） ---------- */
/* 本项目的 alert 均为纯文本提示，恢复为块级文本流，
   避免 Tabler 默认 display:flex 把行内 <strong> 挤成独立一行导致排版断裂 */
.alert {
  display: block;
  line-height: 1.7;
}

.alert.success {
  color: #1c7c3a;
  background: rgba(47, 179, 68, .08);
  border: 1px solid rgba(47, 179, 68, .3);
}

.alert.error {
  color: #b02525;
  background: rgba(214, 57, 57, .07);
  border: 1px solid rgba(214, 57, 57, .3);
}

.alert.info {
  color: #1a569d;
  background: rgba(32, 107, 196, .08);
  border: 1px solid rgba(32, 107, 196, .3);
}

/* ---------- 分页（div.pagination 旧结构） ---------- */
div.pagination {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: .5rem;
  margin: 1rem 0 0;
  color: var(--text-muted);
  font-size: .8125rem;
}

/* ---------- 弹窗（modal-mask/modal-box 旧机制，Tabler 观感） ---------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1055;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 36, 51, .4);
  padding: 1rem;
}

.modal-box {
  background: var(--card-bg);
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(24, 36, 51, .22);
  width: 100%;
  max-width: 560px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 1.5rem;
}

.modal-box.wide {
  max-width: 860px;
}

.modal-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--text);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

/* ---------- 权限勾选网格 ---------- */
.perm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: .5rem;
  margin: .25rem 0 .5rem;
}

.perm-grid label {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  border: 1px solid var(--border);
  border-radius: var(--tblr-border-radius, 4px);
  padding: .5rem .625rem;
  cursor: pointer;
  color: var(--text);
  transition: border-color .15s;
}

.perm-grid label:hover {
  border-color: var(--primary);
}

.perm-grid input[type="checkbox"] {
  width: auto;
  margin: 0;
  accent-color: var(--primary);
}

/* ---------- 签章定位行 ---------- */
.placement-row {
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  border: 1px solid var(--border);
  border-radius: var(--tblr-border-radius, 4px);
  padding: .625rem;
  margin-bottom: .5rem;
  background: var(--bg);
}

.placement-row .form-group {
  min-width: 90px;
  margin-bottom: 0;
}

/* ---------- 所见即所得签章/头像预览（拖拽定位） ---------- */
.sign-preview-wrap {
  margin-top: .75rem;
  border: 1px solid var(--border);
  border-radius: var(--tblr-border-radius, 4px);
  background: var(--bg);
  padding: .625rem;
}

.sign-preview-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
  font-size: .8125rem;
}

#ai-placement-status {
  flex: 1 1 220px;
  min-width: 180px;
}

#stamp-placement-help {
  flex: 1 1 360px;
}

#ap-page-count {
  white-space: nowrap;
}

.sign-preview-canvas {
  position: relative;
  display: inline-block;
  max-width: 100%;
  line-height: 0;
  background: #fff;
  box-shadow: 0 1px 4px rgba(24, 36, 51, .14);
  border-radius: 2px;
}

.sign-preview-canvas img {
  display: block;
  max-width: 100%;
  height: auto;
}

.placement-overlay {
  position: absolute;
  pointer-events: auto;
  touch-action: none;
  cursor: move;
  user-select: none;
  overflow: visible;
  opacity: .92;
  outline: 1px dashed rgba(214, 57, 57, .6);
}

.placement-overlay.dragging {
  opacity: .78;
  outline: 2px solid var(--primary);
}

.placement-overlay img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.placement-resize-handle {
  position: absolute;
  right: -5px;
  bottom: -5px;
  width: 11px;
  height: 11px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 1px 4px rgba(24, 36, 51, .28);
  cursor: nwse-resize;
}

.photo-placement-overlay {
  outline-color: rgba(32, 107, 196, .85);
}

.photo-placement-overlay img {
  opacity: .86;
  object-fit: cover;
}

.photo-placement-overlay.empty {
  background: rgba(32, 107, 196, .08);
}

.photo-placement-overlay.empty img {
  display: none;
}

.placement-overlay-placeholder {
  display: none;
  height: 100%;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: .8125rem;
  line-height: 1;
}

.photo-placement-overlay.empty .placement-overlay-placeholder {
  display: flex;
}

.pl-seal-thumb {
  width: 46px;
  height: 46px;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: var(--tblr-border-radius, 4px);
  background: #fff;
  padding: 2px;
}

/* ---------- 公开验证页 ---------- */
.verify-wrap {
  max-width: 680px;
  margin: 2.5rem auto;
  padding: 0 1rem;
}

.verify-result-card {
  border-radius: 8px;
  padding: 1.625rem 1.5rem;
  margin: 1rem 0;
  text-align: center;
}

.verify-result-card.pass {
  background: rgba(47, 179, 68, .08);
  border: 1px solid rgba(47, 179, 68, .35);
}

.verify-result-card.fail {
  background: rgba(214, 57, 57, .06);
  border: 1px solid rgba(214, 57, 57, .35);
}

.verify-result-card .icon {
  font-size: 2.5rem;
  line-height: 1;
  margin-bottom: .5rem;
}

.verify-result-card.pass .icon { color: var(--success); }
.verify-result-card.fail .icon { color: var(--danger); }

.verify-result-card h3 {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: .375rem;
}

/* ---------- 布局细节 ---------- */
.page-title {
  font-weight: 600;
}

.mt-0 { margin-top: 0 !important; }
.mb-0 { margin-bottom: 0 !important; }
