:root {
  --navy-950: #0b1422;
  --navy-900: #111d2f;
  --navy-800: #1a2b44;
  --navy-700: #28415f;
  --ink: #172033;
  --muted: #687386;
  --line: #d9dee7;
  --surface: #ffffff;
  --canvas: #f3f5f8;
  --gold: #b68a2b;
  --gold-soft: #f3ead5;
  --green: #19724b;
  --green-soft: #e7f5ee;
  --red: #aa3434;
  --red-soft: #f9e8e8;
  --radius: 7px;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  color: var(--ink);
  background: var(--canvas);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--canvas); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a { -webkit-tap-highlight-color: transparent; }
svg { width: 18px; height: 18px; stroke-width: 1.8; flex: 0 0 auto; }

.app-shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--navy-950); color: #dbe3ef; padding: 24px 16px 16px; display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand img { width: 38px; height: 38px; object-fit: contain; background: #fff; border-radius: 4px; }
.brand span { display: grid; gap: 3px; min-width: 0; }
.brand strong { color: #fff; font-size: 15px; white-space: nowrap; }
.brand small { color: #8e9cb0; font-size: 8px; letter-spacing: 1.4px; }
.sidebar nav { display: grid; gap: 4px; padding-top: 22px; }
.sidebar nav a { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 12px; color: #9eabbd; border-radius: 6px; font-size: 14px; }
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,.05); }
.sidebar nav a.active { color: #fff; background: var(--navy-800); box-shadow: inset 3px 0 var(--gold); }
.sidebar-footer { margin-top: auto; border-top: 1px solid rgba(255,255,255,.1); padding-top: 14px; }
.user-line, .ghost-button { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; color: #9eabbd; font-size: 13px; }
.ghost-button { width: 100%; border: 0; background: transparent; cursor: pointer; border-radius: 5px; }
.ghost-button:hover { color: #fff; background: rgba(255,255,255,.05); }
.main-area { min-width: 0; padding: 32px 38px 60px; }
.mobile-header { display: none; }

.page-head { display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; margin-bottom: 26px; }
.page-head.compact { align-items: center; }
.page-head h1 { margin: 3px 0 5px; font-size: 28px; line-height: 1.25; font-weight: 700; color: var(--navy-900); }
.page-head p { margin: 0; color: var(--muted); font-size: 14px; }
.eyebrow { margin: 0; color: var(--gold) !important; font-size: 10px !important; font-weight: 800; letter-spacing: 1.7px !important; }
.primary-button, .secondary-button, .danger-button { min-height: 40px; border: 1px solid transparent; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 0 16px; cursor: pointer; font-weight: 650; font-size: 13px; white-space: nowrap; }
.primary-button { background: var(--navy-800); color: #fff; }
.primary-button:hover { background: var(--navy-700); }
.secondary-button { background: #fff; color: var(--navy-800); border-color: #cdd4df; }
.secondary-button:hover { border-color: var(--navy-700); }
.danger-button { background: #fff; color: var(--red); border-color: #e4bcbc; }
.danger-button:hover { background: var(--red-soft); }
.full { width: 100%; }

.stats-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat { min-height: 116px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius); padding: 20px; position: relative; display: grid; align-content: space-between; }
.stat span { color: var(--muted); font-size: 13px; }
.stat strong { color: var(--navy-900); font-size: 30px; font-variant-numeric: tabular-nums; }
.stat svg { position: absolute; right: 18px; top: 18px; color: var(--gold); width: 20px; height: 20px; }
.content-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; }
.content-section.no-top { border-top-left-radius: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.section-head h2, .action-panel h2 { margin: 0 0 4px; font-size: 16px; color: var(--navy-900); }
.section-head p { margin: 0; color: var(--muted); font-size: 12px; }
.text-link { color: var(--navy-700); font-size: 13px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 720px; }
th { padding: 11px 12px; background: #f7f8fa; color: #657084; font-size: 11px; text-align: left; font-weight: 700; border-bottom: 1px solid var(--line); }
td { padding: 14px 12px; font-size: 13px; border-bottom: 1px solid #e8ebf0; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfc; }
.mono { font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.copyable { cursor: copy; position: relative; }
.copyable.copied::after { content: "已复制"; position: absolute; left: 12px; top: 2px; color: var(--green); font-size: 10px; background: #fff; padding: 1px 4px; }
.status { display: inline-flex; min-height: 24px; align-items: center; padding: 0 9px; border-radius: 99px; font-size: 11px; font-weight: 750; }
.status.active { color: var(--green); background: var(--green-soft); }
.status.void { color: var(--red); background: var(--red-soft); }
.status.large { min-height: 32px; padding: 0 13px; font-size: 12px; }
.icon-link, .icon-button { width: 34px; height: 34px; border: 1px solid #d6dce5; background: #fff; border-radius: 5px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--navy-700); }
.icon-link:hover, .icon-button:hover { border-color: var(--navy-700); }
.empty { text-align: center; color: var(--muted); padding: 38px; }
.toolbar { display: flex; margin-bottom: -1px; }
.segmented { display: inline-flex; background: #e6eaf0; padding: 3px; border-radius: 6px 6px 0 0; }
.segmented a { padding: 8px 16px; color: var(--muted); font-size: 12px; font-weight: 700; border-radius: 4px; }
.segmented a.active { background: #fff; color: var(--navy-900); }

.editor-layout { display: grid; grid-template-columns: minmax(360px, 470px) minmax(520px, 1fr); gap: 24px; align-items: start; }
.editor-form, .settings-form { display: grid; gap: 16px; }
.form-section { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 21px; display: grid; gap: 16px; }
.form-section-title { display: flex; align-items: center; gap: 12px; border-bottom: 1px solid #e7eaf0; padding-bottom: 14px; }
.form-section-title > span { color: var(--gold); font-size: 11px; font-weight: 800; }
.form-section-title h2 { margin: 0 0 3px; font-size: 15px; }
.form-section-title p { margin: 0; font-size: 11px; color: var(--muted); }
label { color: #445065; font-size: 12px; font-weight: 700; display: grid; gap: 7px; }
label small { color: var(--muted); font-size: 10px; font-weight: 500; }
input, select, textarea { width: 100%; min-height: 42px; border: 1px solid #cfd5df; border-radius: 5px; background: #fff; color: var(--ink); padding: 9px 11px; outline: none; }
textarea { resize: vertical; line-height: 1.65; }
input:focus, select:focus, textarea:focus { border-color: var(--navy-700); box-shadow: 0 0 0 3px rgba(40,65,95,.1); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, minmax(0,1fr)); }
.preview-stage { background: #dfe4ea; border: 1px solid #cdd3dc; border-radius: var(--radius); padding: 0 22px 30px; min-height: 700px; overflow: hidden; }
.preview-toolbar { height: 52px; display: flex; align-items: center; justify-content: space-between; color: #4f5d70; font-size: 12px; }
.preview-toolbar span { display: flex; gap: 8px; align-items: center; }
.preview-scale { font-family: Consolas, monospace; font-size: 10px !important; }
.paper { width: min(100%, 760px); aspect-ratio: 210 / 297; min-height: 700px; margin: 0 auto; background: #fff; box-shadow: 0 12px 32px rgba(16,26,42,.16); padding: 34px 54px 44px; position: relative; overflow: hidden; font-family: SimSun, "Songti SC", serif; color: #1d2530; }
.paper-header { display: grid; grid-template-columns: 48px 1fr 76px; align-items: center; gap: 12px; }
.paper-header img { width: 44px; height: 44px; object-fit: contain; }
.paper-header > div:nth-child(2) { display: grid; gap: 3px; }
.paper-header strong { font-size: 15px; }
.paper-header small { font-family: Arial, sans-serif; font-size: 6px; }
.qr-placeholder { justify-self: end; width: 58px; height: 58px; border: 1px solid #222; display: grid; place-items: center; align-content: center; gap: 2px; }
.qr-placeholder svg { width: 28px; height: 28px; }
.qr-placeholder span { font-family: Arial, sans-serif; font-size: 6px; }
.paper-rule { height: 1px; background: #26364e; margin: 8px 0 16px; }
.paper h2 { text-align: center; margin: 0 0 8px; font-size: 22px; font-weight: 600; }
.paper-meta { display: grid; justify-items: end; font-size: 9px; line-height: 1.7; margin-bottom: 24px; }
.paper p { font-size: 10px; line-height: 1.95; margin: 0 0 7px; text-align: justify; text-indent: 2em; }
.paper-beneficiary { text-indent: 0 !important; margin-bottom: 13px !important; }
.doc-field, .paper u { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.paper-sign { margin-top: 18px; }
.paper-sign p { text-align: right; text-indent: 0; font-size: 9px; line-height: 1.55; margin: 0; }
.paper-watermark { position: absolute; inset: 42% auto auto 12%; width: 76%; transform: rotate(-28deg); color: rgba(56,74,100,.07); font-family: "Microsoft YaHei", sans-serif; font-size: 44px; font-weight: 800; text-align: center; pointer-events: none; }
.alert { border: 1px solid; border-radius: 5px; padding: 12px 14px; font-size: 12px; line-height: 1.55; }
.alert.error { color: var(--red); background: var(--red-soft); border-color: #ecc8c8; }
.alert.warning { color: #745516; background: #faf3df; border-color: #ead8a8; }
.alert.success { color: var(--green); background: var(--green-soft); border-color: #bee2d0; margin-bottom: 16px; }

.detail-grid { display: grid; grid-template-columns: minmax(0,1fr) 280px; gap: 18px; align-items: start; }
.detail-list, .public-fields { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); border-top: 1px solid var(--line); }
.detail-list div, .public-fields div { padding: 15px 10px; border-bottom: 1px solid #e7eaf0; }
.detail-list .wide, .public-fields .wide { grid-column: 1 / -1; }
dt { color: var(--muted); font-size: 11px; margin-bottom: 5px; }
dd { margin: 0; font-size: 13px; line-height: 1.55; }
.action-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 10px; }
.action-panel h2 { margin-bottom: 6px; }
.divider { height: 1px; background: var(--line); margin: 5px 0; }
.void-form { margin: 0; }

.template-layout { display: grid; grid-template-columns: 340px minmax(0,1fr); gap: 18px; align-items: start; }
.form-stack { display: grid; gap: 14px; }
.file-field input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-field span { min-height: 42px; border: 1px dashed #b9c2cf; border-radius: 5px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--navy-700); cursor: pointer; background: #f8f9fb; }
.template-items { display: grid; }
.template-item { min-height: 78px; display: grid; grid-template-columns: 44px minmax(0,1fr) auto 34px; align-items: center; gap: 14px; border-top: 1px solid #e7eaf0; }
.template-item:first-child { border-top: 0; }
.template-icon { width: 40px; height: 40px; display: grid; place-items: center; background: var(--gold-soft); color: #88651c; border-radius: 5px; }
.template-item h3 { margin: 0 0 4px; font-size: 13px; }
.template-item p { margin: 0; color: var(--muted); font-size: 11px; }
.settings-form { max-width: 980px; }
.template-config { max-width: 1080px; }
.form-actions { display: flex; justify-content: flex-end; }
.toggle-row { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 9px; }
.toggle-row input { width: 18px; min-height: 18px; accent-color: var(--navy-700); }
.token-strip { display: flex; flex-wrap: wrap; gap: 7px; }
.token-strip code { color: #65501b; background: var(--gold-soft); border: 1px solid #e7d4a8; border-radius: 4px; padding: 5px 7px; font-size: 10px; }

.login-page { background: #edf0f4; min-height: 100vh; }
.login-layout { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, .9fr) minmax(420px, 1.1fr); }
.login-identity { background: var(--navy-950); color: #fff; padding: 11vh 9vw; display: flex; flex-direction: column; justify-content: center; }
.login-identity img { width: 70px; height: 70px; object-fit: contain; background: #fff; border-radius: 5px; margin-bottom: 32px; }
.login-identity h1 { font-size: 36px; margin: 8px 0 12px; }
.login-identity > p:not(.eyebrow) { color: #aab5c5; margin: 0; line-height: 1.7; }
.identity-rule { height: 2px; width: 72px; background: var(--gold); margin: 36px 0 18px; }
.login-identity small { color: #7f8da1; line-height: 1.7; max-width: 380px; }
.login-panel { display: grid; place-items: center; padding: 40px; }
.login-form-wrap { width: min(100%, 400px); }
.login-form-wrap h2 { margin: 8px 0 6px; font-size: 26px; }
.login-form-wrap .muted { margin: 0 0 26px; color: var(--muted); font-size: 13px; }
.login-form-wrap .alert { margin-bottom: 14px; }

.verify-page { min-height: 100vh; background: #eef1f5; }
.verify-header { height: 72px; background: var(--navy-950); display: flex; align-items: center; padding: 0 max(24px, calc((100vw - 920px)/2)); color: #fff; }
.verify-brand { display: flex; align-items: center; gap: 12px; }
.verify-brand img { width: 38px; height: 38px; background: #fff; border-radius: 4px; }
.verify-brand span { display: grid; gap: 2px; }
.verify-brand strong { font-size: 14px; }
.verify-brand small { color: #8795aa; font-size: 7px; letter-spacing: 1.4px; }
.verify-main { width: min(100% - 32px, 720px); margin: 0 auto; padding: 54px 0 70px; }
.verify-intro { text-align: center; margin-bottom: 24px; }
.verify-intro h1 { font-size: 30px; margin: 8px 0 7px; }
.verify-intro > p:not(.eyebrow) { margin: 0; color: var(--muted); font-size: 13px; }
.verify-panel { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: var(--radius); padding: 28px; }
.verify-number { display: flex; justify-content: space-between; gap: 20px; align-items: center; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.verify-number span { color: var(--muted); font-size: 12px; }
.verify-number strong { font-family: Consolas, monospace; font-size: 14px; }
.verify-form { display: grid; gap: 16px; margin-top: 22px; }
.verify-result { margin: 22px 0 8px; border-radius: 6px; padding: 17px; display: flex; align-items: center; gap: 14px; }
.verify-result.active { color: var(--green); background: var(--green-soft); }
.verify-result.void { color: var(--red); background: var(--red-soft); }
.verify-result svg { width: 30px; height: 30px; }
.verify-result > div { display: grid; gap: 4px; }
.verify-result strong { font-size: 14px; }
.verify-result span { font-size: 11px; opacity: .8; }
.public-fields { margin-top: 20px; }
.verify-footnote { color: #7b8594; font-size: 10px; text-align: center; line-height: 1.6; }

@media (max-width: 1080px) {
  .main-area { padding: 28px 24px 50px; }
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .editor-layout { grid-template-columns: minmax(330px, 420px) minmax(420px, 1fr); }
  .paper { padding: 28px 38px; }
  .paper p { font-size: 9px; line-height: 1.8; }
  .template-layout { grid-template-columns: 300px minmax(0,1fr); }
}

@media (max-width: 820px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; left: -250px; width: 236px; transition: left .2s ease; box-shadow: 12px 0 28px rgba(0,0,0,.2); }
  .nav-open .sidebar { left: 0; }
  .main-area { padding: 0 16px 42px; }
  .mobile-header { display: flex; height: 62px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); margin: 0 -16px 22px; padding: 0 16px; background: #fff; }
  .mobile-brand { font-size: 14px; font-weight: 800; color: var(--navy-900); }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 23px; }
  .editor-layout, .template-layout, .detail-grid { grid-template-columns: 1fr; }
  .preview-stage { order: -1; padding: 0 10px 18px; min-height: 0; }
  .paper { min-height: 0; padding: 22px 26px; }
  .paper p { font-size: clamp(6px, 1.8vw, 9px); line-height: 1.65; }
  .paper h2 { font-size: 16px; }
  .paper-header { grid-template-columns: 34px 1fr 46px; gap: 8px; }
  .paper-header img { width: 32px; height: 32px; }
  .paper-header strong { font-size: 10px; }
  .qr-placeholder { width: 42px; height: 42px; }
  .qr-placeholder svg { width: 20px; height: 20px; }
  .paper-meta { margin-bottom: 12px; font-size: 6px; }
  .paper-watermark { font-size: 7vw; }
  .action-panel { position: static; }
}

@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 9px; }
  .stat { min-height: 96px; padding: 15px; }
  .stat strong { font-size: 24px; }
  .page-head { display: grid; gap: 14px; }
  .page-head > .primary-button { width: 100%; }
  .form-grid, .form-grid.three, .detail-list, .public-fields { grid-template-columns: 1fr; }
  .detail-list .wide, .public-fields .wide { grid-column: auto; }
  .content-section, .form-section, .verify-panel { padding: 16px; }
  .template-item { grid-template-columns: 38px minmax(0,1fr) 34px; }
  .template-item .status { display: none; }
  .login-layout { display: block; min-height: 100vh; }
  .login-identity { min-height: 34vh; padding: 42px 28px; justify-content: flex-end; }
  .login-identity img { width: 50px; height: 50px; margin-bottom: 18px; }
  .login-identity h1 { font-size: 27px; }
  .identity-rule, .login-identity small { display: none; }
  .login-panel { padding: 36px 24px; }
  .verify-main { padding-top: 36px; }
  .verify-intro h1 { font-size: 25px; }
  .verify-number { align-items: flex-start; flex-direction: column; gap: 6px; }
}
