:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --border: #e3e8ef;
  --text: #1d2939;
  --muted: #667085;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eff4ff;
  --success: #15803d;
  --success-soft: #ecfdf3;
  --warn: #b45309;
  --warn-soft: #fffaeb;
  --danger: #b42318;
  --danger-soft: #fef3f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- 顶栏 ---------- */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 24px;
  height: 60px; display: flex; align-items: center; gap: 28px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; white-space: nowrap; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; letter-spacing: -1px;
}
.nav { display: flex; gap: 4px; flex: 1; }
.nav a {
  padding: 7px 13px; border-radius: 7px; color: var(--muted); font-weight: 500;
}
.nav a:hover { background: var(--bg); text-decoration: none; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 10px; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1180px; margin: 0 auto; padding: 26px 24px 60px; }
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 22px; margin: 0 0 5px; letter-spacing: -.3px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: #fcfdff;
}
.card-head h2 { font-size: 15px; margin: 0; font-weight: 650; display: flex; align-items: center; gap: 9px; }
.card-head .sub { color: var(--muted); font-size: 12px; font-weight: 400; }
.card-body { padding: 20px; }
.card-body.tight { padding: 14px 20px; }

.step-no {
  width: 21px; height: 21px; border-radius: 6px; background: var(--primary);
  color: #fff; font-size: 12px; display: inline-flex; align-items: center;
  justify-content: center; font-weight: 700; flex: none;
}

/* ---------- 表单 ---------- */
.grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: #344054; }
.field .hint { font-size: 11.5px; color: var(--muted); line-height: 1.5; }
input[type=text], input[type=password], input[type=date], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid #d0d5dd; border-radius: 7px;
  background: #fff; color: var(--text); font-size: 13.5px; font-family: inherit;
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.6; }
input[type=color] { width: 42px; height: 36px; padding: 2px; border: 1px solid #d0d5dd; border-radius: 7px; background: #fff; }
.check { display: flex; align-items: flex-start; gap: 8px; cursor: pointer; font-size: 13px; }
.check input { margin-top: 4px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: 7px; border: 1px solid transparent;
  font-size: 13.5px; font-weight: 600; font-family: inherit; cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s; white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-outline { background: #fff; color: #344054; border-color: #d0d5dd; }
.btn-outline:hover:not(:disabled) { background: #f9fafb; }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover:not(:disabled) { background: var(--primary-soft); }
.btn-danger { background: #fff; color: var(--danger); border-color: #fecdca; }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }
.btn-lg { padding: 11px 22px; font-size: 14.5px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ---------- 上传 ---------- */
.upload {
  border: 2px dashed #cbd5e1; border-radius: 10px; background: #fbfcff;
  padding: 34px 20px; text-align: center; cursor: pointer; transition: all .15s;
}
.upload:hover, .upload.drag { border-color: var(--primary); background: var(--primary-soft); }
.upload .u-icon { font-size: 30px; line-height: 1; color: var(--primary); margin-bottom: 10px; }
.upload .u-main { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.upload .u-sub { font-size: 12.5px; color: var(--muted); }
.upload input[type=file] { display: none; }
.file-chip {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: #fcfdff;
}
.file-chip .fname { font-weight: 600; flex: 1; word-break: break-all; font-size: 13px; }
.file-chip .fmeta { color: var(--muted); font-size: 12px; }

/* ---------- 摘要 ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { border: 1px solid var(--border); border-radius: 8px; padding: 12px 14px; background: #fcfdff; }
.stat .k { font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.stat .v { font-size: 17px; font-weight: 700; letter-spacing: -.3px; word-break: break-all; }
.stat .v.small { font-size: 13.5px; font-weight: 600; }
.stat .v.money { color: var(--primary); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
table.data th {
  background: #f8fafc; color: #475467; font-weight: 650; text-align: left;
  padding: 9px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0;
}
table.data td { padding: 7px 10px; border-bottom: 1px solid #f0f2f5; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fafcff; }
table.data tr.off td { opacity: .45; }
table.data td.num, table.data th.num, table.data span.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data span.num { display: block; }
table.data input[type=text] { padding: 4px 7px; font-size: 12px; min-width: 90px; }
table.data .mini { min-width: 60px; }
.tfoot { padding: 10px 12px; background: #f8fafc; border-top: 1px solid var(--border); font-size: 13px; display: flex; gap: 26px; flex-wrap: wrap; }
.tfoot b { color: var(--primary); font-variant-numeric: tabular-nums; }

/* ---------- 提示 ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 600; }
.badge.blue { background: var(--primary-soft); color: var(--primary); }
.badge.green { background: var(--success-soft); color: var(--success); }
.badge.amber { background: var(--warn-soft); color: var(--warn); }
.badge.gray { background: #f2f4f7; color: #475467; }
.notice { padding: 11px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; border: 1px solid transparent; }
.notice.info { background: var(--primary-soft); border-color: #c7d7fe; color: #1e40af; }
.notice.warn { background: var(--warn-soft); border-color: #fedf89; color: #92400e; }
.notice.error { background: var(--danger-soft); border-color: #fecdca; color: #912018; }
.notice.ok { background: var(--success-soft); border-color: #abefc6; color: #166534; }
.notice a { font-weight: 600; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }
.section-title { font-size: 13px; font-weight: 700; color: #344054; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ''; width: 3px; height: 14px; background: var(--primary); border-radius: 2px; }
details.adv { border: 1px solid var(--border); border-radius: 8px; background: #fcfdff; }
details.adv > summary { padding: 11px 14px; cursor: pointer; font-weight: 600; font-size: 13px; list-style: none; user-select: none; }
details.adv > summary::before { content: '▸ '; color: var(--primary); }
details.adv[open] > summary::before { content: '▾ '; }
details.adv > div { padding: 4px 16px 18px; }

.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 100;
  background: #101828; color: #fff; padding: 12px 18px; border-radius: 8px;
  box-shadow: 0 8px 28px rgba(16, 24, 40, .22); font-size: 13.5px;
  max-width: 420px; opacity: 0; transform: translateY(10px); transition: all .2s; pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.err { background: #b42318; }

/* ---------- 登录 / 帮助 ---------- */
.login-box { max-width: 400px; margin: 70px auto; }
.var-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 20px; }
.var-list code { background: #f2f4f7; padding: 2px 6px; border-radius: 4px; color: #b42318; font-size: 12px; }
.doc h3 { font-size: 15px; margin: 22px 0 8px; }
.doc p, .doc li { font-size: 13.5px; color: #344054; line-height: 1.85; }
.doc ol, .doc ul { padding-left: 22px; }
.doc code { background: #f2f4f7; padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }

@media (max-width: 900px) {
  .grid, .grid.g2, .grid.g4, .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 620px) {
  .topbar-inner { padding: 0 14px; gap: 12px; height: auto; min-height: 56px; flex-wrap: wrap; }
  .wrap { padding: 18px 14px 40px; }
  .grid, .grid.g2, .grid.g4, .stats, .var-list { grid-template-columns: 1fr; }
  .nav { order: 3; width: 100%; padding-bottom: 8px; }
}
