:root {
  --bg: #f4f7fb;
  --panel: #fff;
  --line: #e4eaf2;
  --text: #172033;
  --muted: #718096;
  --blue: #2667ff;
  --blue-soft: #eaf0ff;
  --green: #0f9f6e;
  --green-soft: #e8f8f1;
  --amber: #b77900;
  --amber-soft: #fff5dc;
  --red: #d64545;
  --red-soft: #feecec;
  --purple: #7a5af8;
  --purple-soft: #f0ecff;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(20, 37, 63, 0.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}
a { color: var(--blue); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.loading { padding: 80px; text-align: center; color: var(--muted); }
.hidden { display: none !important; }

/* login */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 15% 20%, rgba(38, 103, 255, 0.16), transparent 34%),
    radial-gradient(circle at 85% 80%, rgba(15, 159, 110, 0.12), transparent 36%),
    #f2f6fc;
  padding: 24px;
}
.login-card {
  width: min(420px, 100%);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px;
  box-shadow: 0 24px 60px rgba(20, 37, 63, 0.12);
}
.login-logo { width: 46px; height: 46px; border-radius: 13px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 24px; }
.login-card h1 { font-size: 24px; margin: 18px 0 6px; }
.login-card .sub { color: var(--muted); margin-bottom: 24px; }
.login-divider { display: flex; align-items: center; gap: 10px; color: #9aa7b8; font-size: 12px; margin: 18px 0; }
.login-divider::before, .login-divider::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.login-foot { color: #9aa7b8; font-size: 12px; margin-top: 20px; line-height: 1.7; }

/* shell */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  flex: 0 0 220px;
  background: #fff;
  border-right: 1px solid var(--line);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 4px 8px 22px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--blue); color: #fff; display: grid; place-items: center; font-size: 18px; }
.brand b { display: block; font-size: 15px; }
.brand span { display: block; font-size: 11px; color: var(--muted); }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-label { font-size: 11px; color: #a3afc0; padding: 16px 10px 6px; letter-spacing: .08em; }
.nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  color: #42526b;
  font-weight: 500;
}
.nav a:hover { background: #f5f8fd; }
.nav a.active { background: var(--blue-soft); color: var(--blue); }
.nav a .ico { width: 20px; text-align: center; }
.sidebar-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 8px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-weight: 700; }
.user-chip b { display: block; font-size: 13px; }
.user-chip small { color: var(--muted); display: block; font-size: 11px; }
.logout { border: 0; background: none; color: var(--muted); font-size: 12px; padding: 8px; text-align: left; }
.logout:hover { color: var(--red); }

.main { min-width: 0; flex: 1; }
.topbar {
  height: 62px;
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 { font-size: 16px; margin: 0; }
.topbar .crumb { color: var(--muted); font-size: 12px; margin-left: 12px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 24px 26px 60px; max-width: 1280px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 25px; letter-spacing: -.02em; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* atoms */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: #33415c;
  font-weight: 600;
  font-size: 13px;
}
.btn:hover { border-color: #c8d5e6; background: #fafcff; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: #1f56d8; }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 30px; padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.input, .select, .textarea {
  width: 100%;
  min-height: 38px;
  padding: 8px 11px;
  border: 1px solid #d9e2ee;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(38,103,255,.1); }
.textarea { min-height: 84px; resize: vertical; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: #4a5a72; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.row { display: flex; gap: 12px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.strong { font-weight: 700; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-title { font-weight: 700; font-size: 15px; }
.mt-16 { margin-top: 16px; }
.mb-16 { margin-bottom: 16px; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; background: #f1f4f9; color: #50617a; font-size: 11px; font-weight: 600; }
.chip.blue { background: var(--blue-soft); color: var(--blue); }
.chip.green { background: var(--green-soft); color: var(--green); }
.chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.red { background: var(--red-soft); color: var(--red); }
.chip.purple { background: var(--purple-soft); color: var(--purple); }
.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.pending { color: var(--amber); }
.status.archived { color: var(--green); }
.status.rejected { color: var(--red); }
.status.waiting { color: var(--muted); }
.status.approved { color: var(--green); }
.status.cancelled { color: #9aa7b8; }

/* dashboard */
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 29px; font-weight: 750; letter-spacing: -.03em; margin: 4px 0 0; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 3px; }
.stat.blue .value { color: var(--blue); }
.stat.green .value { color: var(--green); }
.stat.amber .value { color: var(--amber); }
.stat.red .value { color: var(--red); }
.dash-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; }
.recent-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eef2f7; }
.recent-row:last-child { border-bottom: 0; }
.recent-row .doc-name { font-weight: 650; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-row .meta { color: var(--muted); font-size: 12px; }
.recent-row .right { margin-left: auto; text-align: right; }
.quick-link { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-bottom: 1px solid #eef2f7; color: #33415c; }
.quick-link:last-child { border-bottom: 0; }
.quick-link:hover { color: var(--blue); }

/* table */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 700; color: #8493a8; letter-spacing: .04em; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f9fbff; }
.table .clickable { cursor: pointer; }
.table .doc-title { font-weight: 650; }
.table .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* upload */
.upload-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 18px; align-items: start; }
.dropzone {
  border: 1.5px dashed #bfd0e6;
  border-radius: 12px;
  padding: 30px 20px;
  text-align: center;
  color: var(--muted);
  background: #fbfdff;
  cursor: pointer;
  transition: .15s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--blue); background: var(--blue-soft); color: var(--blue); }
.dropzone .big { font-size: 30px; display: block; margin-bottom: 6px; }
.dropzone b { color: #33415c; }
.file-picked { display: flex; align-items: center; gap: 8px; margin-top: 10px; color: #33415c; font-weight: 600; }
.file-picked button { margin-left: auto; }
.side-note { font-size: 12px; color: var(--muted); line-height: 1.9; }
.side-note b { color: #44546c; }

/* detail */
.detail-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 16px; }
.detail-head h1 { font-size: 23px; margin: 0 0 6px; }
.detail-head .sub { color: var(--muted); }
.detail-grid { display: grid; grid-template-columns: 1.4fr .6fr; gap: 16px; align-items: start; }
.kv { display: grid; grid-template-columns: 90px 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #eef2f7; }
.file-row:last-child { border-bottom: 0; }
.file-icon { width: 34px; height: 34px; border-radius: 8px; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; }
.file-row .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .sub { color: var(--muted); font-size: 11px; }
.file-row .action { margin-left: auto; }
.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 18px 12px; }
.tl-item::before { content: ""; position: absolute; left: -18px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: #c5d1e2; border: 2px solid #fff; }
.tl-item.done::before { background: var(--green); }
.tl-item.current::before { background: var(--amber); box-shadow: 0 0 0 4px var(--amber-soft); }
.tl-item.rejected::before { background: var(--red); }
.tl-item .role { font-weight: 700; }
.tl-item .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.tl-item .comment { background: #f7f9fc; border-radius: 8px; padding: 8px 10px; margin-top: 7px; color: #4b5b72; font-size: 12px; }
.review-actions { display: flex; gap: 8px; margin-top: 10px; }
.callout { border: 1px solid #dce7f7; background: #f5f9ff; border-radius: 10px; padding: 11px 13px; color: #47617e; font-size: 12px; line-height: 1.7; }
.callout.warn { border-color: #f1dfb4; background: #fffaf0; color: #7d621f; }
.callout.danger { border-color: #f1caca; background: #fff7f7; color: #8d3d3d; }

/* admin */
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar .input, .toolbar .select { width: auto; min-width: 180px; }
.role-row { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #eef2f7; }
.role-row:last-child { border-bottom: 0; }
.role-row .role-name { width: 180px; font-weight: 650; }
.role-row .people { flex: 1; color: #52647c; font-size: 12px; }
.role-row .status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c5d1e2; }
.role-row .status-dot.ready { background: var(--green); }
.role-row .status-dot.missing { background: var(--red); }
.flow-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start; }
.flow-list { max-height: 680px; overflow: auto; }
.flow-list-item { padding: 10px 12px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.flow-list-item:hover { background: #f6f9fe; }
.flow-list-item.active { background: var(--blue-soft); color: var(--blue); font-weight: 650; }
.flow-list-item .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.flow-step { display: grid; grid-template-columns: 34px 1fr 110px 70px; gap: 9px; align-items: center; padding: 9px 0; border-bottom: 1px solid #eef2f7; }
.flow-step .num { width: 24px; height: 24px; border-radius: 50%; background: var(--blue-soft); color: var(--blue); display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.flow-step .tools { display: flex; gap: 4px; justify-content: flex-end; }
.icon-btn { border: 1px solid var(--line); background: #fff; border-radius: 7px; width: 28px; height: 28px; display: grid; place-items: center; color: #5b6b82; }
.icon-btn:hover { color: var(--blue); border-color: #bfd0e6; }

/* modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 27, 43, .45); display: grid; place-items: center; z-index: 100; padding: 20px; }
.modal { background: #fff; border-radius: 14px; width: min(620px, 100%); max-height: 86vh; overflow: hidden; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(10, 20, 35, .22); }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-head button { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 8px; }
.check-list { max-height: 340px; overflow: auto; border: 1px solid var(--line); border-radius: 9px; }
.check-row { display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-bottom: 1px solid #eef2f7; font-size: 13px; }
.check-row:last-child { border-bottom: 0; }
.check-row:hover { background: #f7faff; }
.check-row .sub { color: var(--muted); font-size: 11px; }
.check-row input { width: 16px; height: 16px; }
.check-row .grow { flex: 1; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #172033; color: #fff; padding: 10px 16px; border-radius: 9px; font-size: 13px; z-index: 200; box-shadow: 0 12px 30px rgba(0,0,0,.2); max-width: 80vw; }
.toast.error { background: #b52b2b; }

@media (max-width: 980px) {
  .shell { display: block; }
  .sidebar { width: auto; height: auto; position: static; padding: 10px 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding: 2px 4px 10px; }
  .nav { flex-direction: row; overflow-x: auto; gap: 4px; }
  .nav-label, .sidebar-foot { display: none; }
  .nav a { white-space: nowrap; padding: 8px 10px; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid, .upload-grid, .detail-grid { grid-template-columns: 1fr; }
  .flow-layout { grid-template-columns: 1fr; }
  .flow-list { max-height: 220px; }
}
@media (max-width: 620px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .page-head { flex-wrap: wrap; }
  .page-head .actions { width: 100%; margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .flow-step { grid-template-columns: 28px 1fr 90px 64px; }
  .role-row { flex-wrap: wrap; }
  .role-row .role-name { width: 100%; }
}
