/* ══════════════════════════════════════════════════════
   电子公章管理系统 · 全局样式
   ══════════════════════════════════════════════════════ */
:root {
  --brand: #2b4a7a;        /* 主品牌蓝 */
  --brand-d: #1d3358;
  --seal: #c0392b;         /* 公章红 */
  --ok: #1e8e5a;
  --warn: #c98a00;
  --err: #c0392b;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e4e8ef;
  --txt: #1f2733;
  --txt-2: #6b7686;
  --radius: 12px;
  --shadow: 0 6px 22px rgba(20, 40, 80, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }

/* ── 顶栏 ── */
.topbar {
  height: 56px;
  background: linear-gradient(90deg, var(--brand-d), var(--brand));
  color: #fff;
  display: flex; align-items: center;
  padding: 0 18px;
  position: sticky; top: 0; z-index: 50;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.topbar .logo { font-weight: 800; font-size: 16px; letter-spacing: .5px; display: flex; align-items: center; gap: 9px; }
.topbar .logo .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--seal); box-shadow: 0 0 0 3px rgba(192,57,43,.25); }
.topbar nav { display: flex; gap: 4px; margin-left: 26px; flex: 1; overflow-x: auto; }
.topbar nav button {
  background: transparent; border: none; color: rgba(255,255,255,.78);
  padding: 8px 14px; border-radius: 8px; cursor: pointer; font-size: 13px; white-space: nowrap;
}
.topbar nav button:hover { background: rgba(255,255,255,.12); color: #fff; }
.topbar nav button.active { background: rgba(255,255,255,.18); color: #fff; font-weight: 600; }
.topbar .me { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.topbar .me .avatar { width: 30px; height: 30px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; font-weight: 700; }
.topbar .me .logout { background: rgba(255,255,255,.15); border: none; color: #fff; padding: 6px 12px; border-radius: 7px; cursor: pointer; font-size: 12px; }
.topbar .me .logout:hover { background: rgba(255,255,255,.28); }

/* ── 声明横幅 ── */
.declaration-bar {
  background: #fef6e7; border-bottom: 1px solid #f3e2bf; color: #8a6d1f;
  font-size: 12.5px; padding: 7px 18px; display: flex; align-items: center; gap: 8px;
  cursor: pointer;
}
.declaration-bar b { color: #9a6a00; }
.declaration-bar .close { margin-left: auto; cursor: pointer; color: #b08a30; font-weight: 700; padding: 0 6px; }

/* ── 布局 ── */
.wrap { max-width: 1180px; margin: 0 auto; padding: 22px 18px 60px; }
.view { display: none; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

h2.section-title { font-size: 19px; margin: 4px 0 18px; display: flex; align-items: center; gap: 10px; }
h2.section-title .tag { font-size: 11px; background: var(--brand); color: #fff; padding: 2px 9px; border-radius: 20px; font-weight: 600; }

/* ── 卡片 ── */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px 22px; margin-bottom: 18px; }
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 820px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── 表单 ── */
label.fld { display: block; font-size: 12.5px; color: var(--txt-2); font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=password], input[type=number], input[type=email], input[type=file], select, textarea {
  width: 100%; padding: 9px 12px; border: 1.5px solid var(--line); border-radius: 8px; font-size: 13px; color: var(--txt); background: #fff; transition: border .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { resize: vertical; min-height: 64px; }
.hint { font-size: 11.5px; color: var(--txt-2); margin-top: 4px; }

/* ── 按钮 ── */
.btn { display: inline-flex; align-items: center; gap: 6px; justify-content: center; border: none; border-radius: 8px; padding: 9px 16px; font-size: 13px; font-weight: 600; cursor: pointer; transition: filter .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-seal { background: var(--seal); color: #fff; }
.btn-seal:hover { filter: brightness(1.08); }
.btn-ghost { background: #eef2f8; color: var(--brand); }
.btn-ghost:hover { background: #e2e9f3; }
.btn-danger { background: #fdecea; color: var(--err); }
.btn-danger:hover { background: #f9d7d3; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 11px; font-size: 12px; }

/* ── 状态条 ── */
.status { padding: 9px 13px; border-radius: 8px; font-size: 13px; margin-top: 12px; display: none; }
.status.show { display: block; }
.status-info { background: #eaf1fb; color: #2b4a7a; }
.status-ok { background: #e7f6ee; color: var(--ok); }
.status-warn { background: #fbf3df; color: #9a6a00; }
.status-err { background: #fdecea; color: var(--err); }

/* ── 表格 ── */
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th { text-align: left; color: var(--txt-2); font-weight: 600; font-size: 12px; padding: 9px 10px; border-bottom: 2px solid var(--line); }
table.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:hover td { background: #f8fafd; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-pending { background: #fbf3df; color: #9a6a00; }
.badge-ok { background: #e7f6ee; color: var(--ok); }
.badge-no { background: #fdecea; color: var(--err); }
.badge-role { background: #eaf1fb; color: var(--brand); }
.badge-admin { background: #efe7fb; color: #6b3fa0; }

/* ── 登录/申请 居中卡片 ── */
.auth-center { min-height: calc(100vh - 56px); display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-box { width: 100%; max-width: 420px; }
.auth-box .brand-head { text-align: center; margin-bottom: 20px; }
.auth-box .brand-head .seal-ico { width: 64px; height: 64px; margin: 0 auto 12px; border-radius: 50%; background: var(--seal); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 30px; box-shadow: 0 6px 18px rgba(192,57,43,.3); }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 16px; background: #eef2f8; padding: 4px; border-radius: 10px; }
.auth-tabs button { flex: 1; background: transparent; border: none; padding: 8px; border-radius: 7px; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--txt-2); }
.auth-tabs button.active { background: #fff; color: var(--brand); box-shadow: 0 2px 6px rgba(0,0,0,.06); }

/* ── 工作台 ── */
.workbench { display: grid; grid-template-columns: 440px 1fr; gap: 18px; align-items: start; }
.wb-left { display: flex; flex-direction: column; gap: 18px; align-items: stretch; }
.wb-right { display: flex; min-height: 0; max-height: calc(100vh - 76px); }
.pdf-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.pdf-panel > .panel-body { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.stack { display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 920px) {
  .workbench { grid-template-columns: 1fr; }
  .wb-left { flex-direction: column; }
  .wb-right { max-height: none; }
}
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel-head { padding: 13px 16px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.panel-body { padding: 16px; }

/* 套餐配额提示条 */
.quota-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 14px; border-radius: 10px;
  background: linear-gradient(135deg, #eef4ff, #f7f9fc); border: 1px solid var(--line); font-size: 13px; font-weight: 600; color: var(--brand); }
.quota-bar.full { background: linear-gradient(135deg, #fdecea, #fdf3f2); border-color: #f3c3bd; color: var(--seal); }

.drop-zone { border: 2px dashed var(--line); border-radius: 10px; padding: 26px 16px; text-align: center; color: var(--txt-2); cursor: pointer; transition: border .15s, background .15s; }
.drop-zone.dragover { border-color: var(--brand); background: #f0f5fc; }
.drop-zone .big { font-size: 30px; margin-bottom: 8px; }

/* 预览 */
/* align-items 用 flex-start + 子元素 auto margin 居中：避免放大后横向溢出时左侧被裁切 */
/* scrollbar-gutter: stable → 滚动条槽位恒定预留，clientWidth 不随内容“有无溢出”抖动（缩放测量才稳定） */
#previewScroll { flex: 1 1 auto; min-height: 360px; overflow: auto; scroll-behavior: smooth; scrollbar-gutter: stable; background: #5a6472; border-radius: 10px; padding: 18px; display: flex; flex-direction: column; align-items: flex-start; gap: 20px; }
@media (max-width: 920px) { #previewScroll { max-height: 70vh; } }
/* 预览工具条（缩放） */
.pv-tools { margin-left: auto; display: flex; align-items: center; gap: 6px; font-weight: 400; font-size: 12px; color: var(--txt-2); }
.pv-tools b { min-width: 46px; text-align: center; font-weight: 600; color: var(--brand); }
/* 页码角标 */
.page-badge { position: absolute; top: 8px; right: 8px; padding: 3px 9px; border-radius: 20px;
  background: rgba(24,32,45,.72); color: #fff; font-size: 11px; font-weight: 600; letter-spacing: .3px;
  pointer-events: none; z-index: 3; }
.pdf-page-wrap { position: relative; background: #fff; box-shadow: 0 4px 14px rgba(0,0,0,.18); flex: 0 0 auto; margin-left: auto; margin-right: auto; }
.pdf-canvas { display: block; }
.seal-overlay { position: absolute; cursor: grab; }
.seal-overlay img { width: 100%; height: 100%; pointer-events: none; user-select: none; }
.seal-overlay:active { cursor: grabbing; }
.qf-slice { position: absolute; overflow: hidden; }
.qf-slice img { position: absolute; height: 100%; top: 0; }
.qifeng-guide { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed rgba(192,57,43,.7); }

/* 印章源选择 */
.seal-source { display: flex; gap: 8px; margin-bottom: 12px; }
.seal-source button { flex: 1; }
.seal-pick-list { display: flex; flex-direction: column; gap: 8px; }
.seal-pick-item { display: flex; align-items: center; gap: 10px; padding: 9px 11px; border: 1.5px solid var(--line); border-radius: 9px; cursor: pointer; transition: border .15s; }
.seal-pick-item:hover { border-color: var(--brand); }
.seal-pick-item.selected { border-color: var(--seal); background: #fdf3f2; }
.seal-pick-item img { width: 38px; height: 38px; border-radius: 6px; object-fit: contain; background: #fff; border: 1px solid var(--line); }
.seal-pick-item .meta { flex: 1; min-width: 0; }
.seal-pick-item .meta .nm { font-weight: 600; font-size: 13px; }
.seal-pick-item .meta .sub { font-size: 11px; color: var(--txt-2); }
.seal-pick-item .del { color: var(--err); cursor: pointer; font-size: 12px; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 42px; height: 23px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #cdd5e0; border-radius: 20px; transition: .2s; cursor: pointer; }
.slider:before { content: ''; position: absolute; width: 17px; height: 17px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + .slider { background: var(--brand); }
.switch input:checked + .slider:before { transform: translateX(19px); }
.row-line { display: flex; align-items: center; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); }
.row-line:last-child { border-bottom: none; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(15,25,45,.5); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 440px; box-shadow: 0 20px 60px rgba(0,0,0,.3); overflow: hidden; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 15px; }
.modal-body { padding: 20px; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

/* 杂项 */
.muted { color: var(--txt-2); }
.tiny { font-size: 12px; }
.right { text-align: right; }
.center { text-align: center; }
.mt8 { margin-top: 8px; } .mt16 { margin-top: 16px; } .mb8 { margin-bottom: 8px; }
.flex { display: flex; gap: 10px; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.empty { text-align: center; color: var(--txt-2); padding: 30px 0; font-size: 13px; }
.kbd { font-family: monospace; background: #eef2f8; padding: 1px 6px; border-radius: 4px; font-size: 12px; }
.code-display { font-size: 30px; letter-spacing: 12px; text-align: center; font-weight: 800; color: var(--seal); background: #fdf3f2; padding: 14px; border-radius: 10px; margin: 10px 0; }
.perm-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.perm-grid label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; }
.perm-grid label:hover { border-color: var(--brand); }
