:root {
  --bg: #f4f6f9; --panel: #fff; --line: #e3e7ee; --text: #1f2633; --muted: #6b7587;
  --navy: #1d3b6a; --navy2: #2a5298; --gold: #a8873b; --red: #c8323a; --green: #1f8a5b; --amber: #b7791f;
  --radius: 10px;
  font-family: -apple-system, "PingFang SC", "Hiragino Sans GB", "Helvetica Neue", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-size: 14px; }
body { display: flex; }
a { color: var(--navy2); text-decoration: none; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- 侧栏 */
.side { width: 208px; flex: none; background: var(--navy); color: #dfe6f3; display: flex; flex-direction: column; padding: 18px 12px; }
.brand { display: flex; gap: 10px; align-items: center; padding: 0 6px 20px; }
.brand-mark { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--gold), #d9bb6f); color: var(--navy); font: 800 15px/38px Arial, sans-serif; text-align: center; }
.brand b { display: block; color: #fff; font-size: 15px; }
.brand small { color: #9fb0cc; font-size: 11px; }
.side nav { display: flex; flex-direction: column; gap: 2px; }
.side nav a { color: #c7d2e6; padding: 9px 12px; border-radius: 7px; display: flex; gap: 10px; align-items: center; }
.side nav a i { font-style: normal; width: 16px; text-align: center; opacity: .8; }
.side nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.side nav a.on { background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding: 0 6px; }
.side-foot a { color: #c7d2e6; font-size: 12px; }
.side-foot small { color: #8fa1c0; font-size: 11px; }
.side-foot .btn { color: #dfe6f3; border-color: rgba(255, 255, 255, .25); }

main { flex: 1; min-width: 0; overflow: auto; padding: 22px 28px 60px; }
.loading { color: var(--muted); padding: 60px; text-align: center; }

/* ---------------------------------------------------------------- 通用 */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .grow { flex: 1; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.card + .card { margin-top: 14px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "SF Mono", Menlo, monospace; font-size: 12.5px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn { border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 7px; cursor: pointer; font-size: 13px; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center; }
.btn:hover { border-color: #b9c3d3; }
.btn.primary { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primary:hover { background: var(--navy2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: #fff; }
.btn.danger { color: var(--red); border-color: #efc4c6; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea { font: inherit; border: 1px solid #d5dbe5; border-radius: 6px; padding: 6px 9px; background: #fff; color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(42, 82, 152, .25); border-color: var(--navy2); }
input[type=checkbox], input[type=radio] { width: auto; }
textarea { min-height: 60px; resize: vertical; }
.search { width: 240px; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef1f6; color: #4a5568; white-space: nowrap; }
.tag.green { background: #e3f4ec; color: var(--green); }
.tag.blue { background: #e6eefb; color: var(--navy2); }
.tag.amber { background: #fbf1df; color: var(--amber); }
.tag.red { background: #fbe5e6; color: var(--red); }
.tag.gold { background: #f6efdc; color: #8a6d24; }

table.list { width: 100%; border-collapse: collapse; background: #fff; }
table.list th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #fafbfd; position: sticky; top: 0; white-space: nowrap; }
table.list td { padding: 9px 10px; border-bottom: 1px solid #eef0f4; vertical-align: middle; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #f7f9fc; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(100vh - 170px); background: #fff; }
.empty { text-align: center; color: var(--muted); padding: 40px; }

/* ---------------------------------------------------------------- 总览 */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-bottom: 14px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat b { display: block; font-size: 24px; margin-top: 4px; color: var(--navy); }
.stat small { color: var(--muted); }
.flow { display: flex; gap: 0; align-items: stretch; margin-bottom: 14px; }
.flow > div { flex: 1; background: #fff; border: 1px solid var(--line); padding: 12px 14px; position: relative; }
.flow > div:first-child { border-radius: var(--radius) 0 0 var(--radius); }
.flow > div:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.flow > div + div { border-left: none; }
.flow b { display: block; color: var(--navy); margin-bottom: 3px; }
.flow span { color: var(--muted); font-size: 12px; }
.flow em { font-style: normal; display: inline-block; width: 20px; height: 20px; line-height: 20px; text-align: center; border-radius: 50%; background: var(--gold); color: #fff; font-size: 12px; margin-right: 6px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------------------------------------------------------------- 编辑器 */
.editor { display: grid; grid-template-columns: 440px 1fr; gap: 16px; height: calc(100vh - 110px); }
.editor .form { overflow: auto; padding-right: 4px; }
.preview { background: #e9ecf1; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; display: flex; flex-direction: column; }
.preview-bar { display: flex; gap: 8px; align-items: center; padding: 8px 10px; background: #fff; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.preview iframe { flex: 1; width: 100%; border: 0; background: #e9ecf1; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); background: #fff; margin: 0 0 12px; padding: 10px 14px 14px; }
legend { font-weight: 600; color: var(--navy); padding: 0 6px; font-size: 13px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 12px; }
.fgrid .full { grid-column: 1 / -1; }
label.f { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
label.f .calc { color: var(--navy); font-weight: 600; font-size: 13px; }
.seg { display: inline-flex; border: 1px solid #d5dbe5; border-radius: 7px; overflow: hidden; }
.seg button { border: 0; background: #fff; padding: 7px 14px; cursor: pointer; font: inherit; font-size: 13px; }
.seg button.on { background: var(--navy); color: #fff; }
.warn { background: #fff7e8; border: 1px solid #f1d9a6; color: #8a5a0b; border-radius: 7px; padding: 7px 10px; font-size: 12px; margin-bottom: 8px; }
.info { background: #eef4fd; border: 1px solid #cbdcf5; color: #24497f; border-radius: 7px; padding: 7px 10px; font-size: 12px; margin-bottom: 8px; line-height: 1.6; }
.ok { background: #e9f6ef; border: 1px solid #bfe3cf; color: #1d6b46; border-radius: 7px; padding: 7px 10px; font-size: 12px; margin-bottom: 8px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--bg); padding: 10px 0 2px; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- 弹窗 */
.modal, .drawer { position: fixed; inset: 0; background: rgba(15, 25, 45, .35); z-index: 50; display: flex; }
.modal { align-items: center; justify-content: center; }
.modal-box { background: #fff; border-radius: 12px; width: min(980px, 94vw); max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 18px; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; align-items: center; }
.x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.drawer { justify-content: flex-end; }
.drawer-box { width: min(560px, 96vw); background: #fff; height: 100%; display: flex; flex-direction: column; }
.drawer-body { overflow: auto; padding: 8px 18px 30px; }
dl.kv { display: grid; grid-template-columns: 130px 1fr; margin: 0; }
dl.kv dt { color: var(--muted); padding: 7px 0; border-bottom: 1px solid #f0f2f6; font-size: 12.5px; }
dl.kv dd { margin: 0; padding: 7px 0; border-bottom: 1px solid #f0f2f6; word-break: break-all; }
.drawer h4 { margin: 18px 0 4px; color: var(--navy); font-size: 13px; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px); background: #1f2633; color: #fff; padding: 10px 18px; border-radius: 8px; opacity: 0; transition: .25s; z-index: 99; pointer-events: none; max-width: 70vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--red); }

/* ---------------------------------------------------------------- 设置 */
.company { display: grid; grid-template-columns: 1fr 190px; gap: 16px; }
.seal-box { border: 1px dashed #cfd6e2; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 10px; background: #fcfcfd; }
.seal-box .seal-prev { width: 140px; height: 140px; position: relative; }
.seal-box .seal-prev .seal { position: absolute; inset: 0; width: 100%; height: 100%; }
.seal-box .seal-prev img { width: 100%; height: 100%; object-fit: contain; }

/* ---------------------------------------------------------------- 校验 */
.verify-card { max-width: 640px; }
.verify-result { margin-top: 14px; border-radius: var(--radius); padding: 16px; }
.verify-result.good { background: #e9f6ef; border: 1px solid #bfe3cf; }
.verify-result.bad { background: #fbe9ea; border: 1px solid #f0c3c6; }
.verify-result h3 { margin: 0 0 8px; }
