:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #17212f;
  --ink-2: #5b6678;
  --ink-3: #8b95a6;
  --line: #e4e8f0;
  --primary: #1a5cff;
  --primary-dark: #1245c4;
  --primary-soft: #eaf0ff;
  --ok: #0f9d58;
  --ok-soft: #e7f7ee;
  --warn: #b8860b;
  --warn-soft: #fff6e0;
  --danger: #d93b3b;
  --danger-soft: #fdecec;
  --shadow: 0 1px 2px rgba(16, 30, 54, .04), 0 8px 24px rgba(16, 30, 54, .06);
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: #fff; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 20px;
  padding: 0 20px; height: 58px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 15px; white-space: nowrap; }
.brand .logo {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, #1a5cff, #4b8bff);
  color: #fff; display: grid; place-items: center; font-size: 14px;
}
.nav { display: flex; gap: 4px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  padding: 7px 13px; border-radius: 8px; color: var(--ink-2);
  white-space: nowrap; font-size: 13.5px; font-weight: 500;
}
.nav a:hover { background: #f1f4fa; color: var(--ink); }
.nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.nav .badge-dot {
  display: inline-block; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 17px; text-align: center; margin-left: 5px;
}
.userbox { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: #e8eefc;
  color: var(--primary); display: grid; place-items: center; font-weight: 600; font-size: 13px;
}
.role-tag { font-size: 11.5px; color: var(--ink-3); }

main { max-width: 1180px; margin: 0 auto; padding: 22px 20px 64px; }

/* ---------- 通用 ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-title { font-size: 15px; font-weight: 650; margin: 0 0 4px; display: flex; align-items: center; gap: 8px; }
.card-sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--ink-3); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.right { text-align: right; }
.only-mobile { display: none; }
.hide-mobile { }
h1.page-title { font-size: 20px; margin: 0 0 4px; font-weight: 700; }
.page-sub { color: var(--ink-3); font-size: 13px; margin-bottom: 18px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px; border-radius: 9px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font-size: 13.5px; font-weight: 550; cursor: pointer;
  transition: .15s; white-space: nowrap;
}
.btn:hover { border-color: #cfd6e4; background: #fafbfe; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-ok:hover { filter: brightness(.94); }
.btn-danger { background: #fff; border-color: #f0cccc; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: #f1f4fa; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
label.field { display: block; margin-bottom: 12px; }
label.field > span { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 5px; font-weight: 550; }
input, select, textarea {
  width: 100%; height: 36px; padding: 0 11px; font-size: 13.5px; font-family: inherit;
  color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 9px;
  outline: none; transition: .15s;
}
textarea { height: auto; min-height: 68px; padding: 9px 11px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26, 92, 255, .1); }
input[type="checkbox"] { width: auto; height: auto; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: -6px; margin-bottom: 12px; }

/* ---------- KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 16px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; box-shadow: var(--shadow); }
.kpi .label { font-size: 12.5px; color: var(--ink-3); display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 23px; font-weight: 700; margin-top: 6px; letter-spacing: -.4px; }
.kpi .value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.kpi .foot { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.kpi.accent { background: linear-gradient(135deg, #1a5cff, #3d7dff); color: #fff; border-color: transparent; }
.kpi.accent .label, .kpi.accent .foot { color: rgba(255, 255, 255, .82); }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; font-weight: 600; font-size: 12.5px; color: var(--ink-3);
  padding: 9px 10px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 11px 10px; border-bottom: 1px solid #f0f3f8; vertical-align: middle; }
tbody tr:hover { background: #fafbfe; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.link-cell { color: var(--primary); font-weight: 550; cursor: pointer; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 9px;
  border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap;
  background: #eef1f7; color: var(--ink-2);
}
.badge.draft { background: #eef1f7; color: #5b6678; }
.badge.submitted { background: var(--warn-soft); color: #9a6a00; }
.badge.manager_approved { background: #e8f1ff; color: #1a5cff; }
.badge.finance_approved { background: #eae6ff; color: #5b45c9; }
.badge.paid { background: var(--ok-soft); color: #0b7a44; }
.badge.rejected { background: var(--danger-soft); color: var(--danger); }
.badge.returned { background: #fdeff7; color: #b02a72; }
.badge.approved { background: var(--ok-soft); color: #0b7a44; }
.badge.closed { background: #eef1f7; color: var(--ink-2); }

.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink-2); }

/* ---------- 审核面板 ---------- */
.audit-head {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border-radius: 10px; margin-bottom: 12px;
}
.audit-head.pass { background: var(--ok-soft); }
.audit-head.warn { background: var(--warn-soft); }
.audit-head.fail { background: var(--danger-soft); }
.audit-score { font-size: 26px; font-weight: 700; line-height: 1; }
.audit-list { display: grid; gap: 2px; }
.audit-item { display: flex; gap: 10px; padding: 8px 4px; border-bottom: 1px dashed #eef1f7; font-size: 13px; }
.audit-item:last-child { border-bottom: none; }
.audit-icon { flex: 0 0 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; color: #fff; margin-top: 2px; }
.audit-icon.pass { background: var(--ok); }
.audit-icon.warn { background: #e0a800; }
.audit-icon.fail { background: var(--danger); }
.audit-item .t { font-weight: 550; }
.audit-item .d { color: var(--ink-2); font-size: 12.5px; }

/* ---------- 时间线 ---------- */
.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 14px 4px; }
.tl-item::before {
  content: ""; position: absolute; left: -18px; top: 6px; width: 8px; height: 8px;
  border-radius: 50%; background: #c9d2e3; border: 2px solid #fff;
}
.tl-item.done::before { background: var(--primary); }
.tl-item .who { font-weight: 600; font-size: 13px; }
.tl-item .what { color: var(--ink-2); font-size: 12.5px; }
.tl-item .when { color: var(--ink-3); font-size: 12px; }

/* ---------- 进度条（类别分布） ---------- */
.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 62px 1fr 96px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-track { display: block; height: 8px; background: #eef1f7; border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 8px; background: linear-gradient(90deg, #1a5cff, #6ea0ff); border-radius: 5px; transition: width .3s; }

/* ---------- 附件 ---------- */
.files { display: flex; flex-wrap: wrap; gap: 8px; }
.thumb {
  position: relative; width: 62px; height: 62px; border-radius: 8px; overflow: hidden;
  border: 1px solid var(--line); background: #f7f9fc; display: grid; place-items: center;
  cursor: pointer; font-size: 11px; color: var(--ink-3); text-align: center;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb .del {
  position: absolute; top: 2px; right: 2px; width: 16px; height: 16px; border-radius: 50%;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 11px; line-height: 16px; text-align: center;
  border: none; cursor: pointer; padding: 0;
}
.upload-btn {
  width: 62px; height: 62px; border: 1px dashed #c5cfe2; border-radius: 8px; background: #fbfcfe;
  color: var(--ink-3); font-size: 20px; display: grid; place-items: center; cursor: pointer;
}
.upload-btn:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- 模态框 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(14, 22, 38, .45); z-index: 60;
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade .15s ease;
}
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 90vh; overflow-y: auto; padding: 20px; box-shadow: 0 20px 60px rgba(10, 20, 40, .25);
  animation: pop .16s ease;
}
.modal.wide { max-width: 760px; }
.modal h3 { margin: 0 0 14px; font-size: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.99); } }

/* ---------- 提示 ---------- */
#toast { position: fixed; top: 70px; left: 50%; transform: translateX(-50%); z-index: 90; display: grid; gap: 8px; }
.toast {
  background: #17212f; color: #fff; padding: 10px 16px; border-radius: 10px;
  font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2); animation: pop .16s ease;
  max-width: 90vw;
}
.toast.err { background: #b42b2b; }
.toast.ok { background: #12854c; }

/* ---------- 登录 ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(1000px 500px at 15% -10%, #e6edff 0%, transparent 60%),
  radial-gradient(900px 500px at 100% 0%, #e9f4ff 0%, transparent 55%), #f4f6fa; }
.login-card { width: 100%; max-width: 396px; background: #fff; border-radius: 16px; padding: 30px 26px; box-shadow: 0 18px 50px rgba(20, 40, 80, .1); }
.login-card .logo { width: 44px; height: 44px; border-radius: 12px; background: linear-gradient(135deg, #1a5cff, #4b8bff); color: #fff; display: grid; place-items: center; font-size: 20px; margin-bottom: 14px; }
.login-card h1 { font-size: 19px; margin: 0 0 4px; }
.login-card .sub { color: var(--ink-3); font-size: 13px; margin-bottom: 20px; }
.login-tip { background: #f6f8fd; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; font-size: 12px; color: var(--ink-2); margin-top: 16px; line-height: 1.7; }

.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; font-size: 13px; }
.empty .big { font-size: 30px; margin-bottom: 8px; opacity: .5; }

.section-gap { height: 16px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .grow { flex: 1; min-width: 160px; }
.seg { display: inline-flex; background: #eef1f7; padding: 3px; border-radius: 9px; gap: 2px; }
.seg button {
  border: none; background: transparent; padding: 5px 12px; border-radius: 7px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; font-weight: 550;
}
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16, 30, 54, .1); }

.split { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px 18px; }
.detail-grid .k { font-size: 12px; color: var(--ink-3); }
.detail-grid .v { font-size: 13.5px; font-weight: 550; margin-top: 1px; }

.subsidy-box {
  background: linear-gradient(135deg, #f2f6ff, #eef4ff);
  border: 1px solid #dbe6ff; border-radius: 10px; padding: 14px 16px;
}
.subsidy-box .big { font-size: 22px; font-weight: 700; color: var(--primary); letter-spacing: -.3px; }
.smart-invoice-box {
  margin-bottom: 12px; padding: 13px 14px; border-radius: 10px;
  border: 1px solid #bfd1ff; background: linear-gradient(135deg, #eef4ff, #f8fbff);
}
.smart-invoice-box .btn { flex: 0 0 auto; }

@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; }
  .field-row, .field-row-3 { grid-template-columns: 1fr; }
  main { padding: 16px 12px 60px; }
  .topbar { padding: 0 12px; gap: 10px; }
  .brand span.full { display: none; }
  .kpi .value { font-size: 20px; }
  .userbox .uname, .userbox .role-tag { display: none; }
  h1.page-title { font-size: 18px; }
  .modal { padding: 16px; }
}

/* ---------- 移动端优化 ---------- */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 12px 0; row-gap: 4px; }
  .brand { order: 1; }
  .userbox { order: 2; margin-left: auto; }
  .nav { order: 3; flex: 0 0 100%; width: 100%; padding-bottom: 6px; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .topbar { position: sticky; }

  .table-wrap.stack { overflow: visible; margin: 0; }
  .table-wrap.stack table, .table-wrap.stack thead, .table-wrap.stack tbody,
  .table-wrap.stack tr, .table-wrap.stack td { display: block; width: 100%; }
  .table-wrap.stack thead { display: none; }
  .table-wrap.stack tbody tr {
    border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
    margin-bottom: 10px; background: #fff;
  }
  .table-wrap.stack tbody tr:hover { background: #fff; }
  .table-wrap.stack td {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 14px;
    padding: 5px 0; border: none; text-align: right;
  }
  .table-wrap.stack td::before {
    content: attr(data-label); color: var(--ink-3); font-size: 12.5px; font-weight: 500;
    flex: 0 0 72px; text-align: left;
  }
  .table-wrap.stack td.primary {
    display: block; text-align: left; border-bottom: 1px dashed #eef1f7;
    padding: 0 0 8px; margin-bottom: 4px;
  }
  .table-wrap.stack td.primary::before { display: none; }
  .table-wrap.stack td:empty { display: none; }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1; padding: 5px 6px; font-size: 12.5px; }
  .only-mobile { display: block; }
  .hide-mobile { display: none !important; }
  .kpis { grid-template-columns: 1fr 1fr; gap: 10px; }
  .kpi { padding: 12px; }
  .kpi .value { font-size: 18px; }
  .between > .row { width: 100%; }
}
