:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --line: #e3e8ef;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --success: #16a34a;
  --warn: #d97706;
  --danger: #dc2626;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(15, 23, 42, .06);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ---------- Web 布局 ---------- */
body[data-mode="web"] .layout { display: flex; min-height: 100vh; }
body[data-mode="web"] .sidebar { width: 210px; background: #fff; border-right: 1px solid var(--line); padding: 20px 14px; flex-shrink: 0; }
body[data-mode="web"] .brand { font-size: 18px; font-weight: 700; margin: 4px 8px 24px; color: var(--primary); }
body[data-mode="web"] .nav-item { display: block; width: 100%; border: 0; background: transparent; padding: 11px 12px; border-radius: 8px; text-align: left; color: var(--text); margin-bottom: 4px; font-size: 14px; }
body[data-mode="web"] .nav-item:hover { background: #f1f5f9; }
body[data-mode="web"] .nav-item.active { background: #e8f0fe; color: var(--primary); font-weight: 600; }
body[data-mode="web"] .main { flex: 1; padding: 24px 32px; overflow: auto; }
body[data-mode="web"] .topbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
body[data-mode="web"] .topbar h1 { font-size: 20px; margin: 0; }

/* ---------- H5 布局 ---------- */
body[data-mode="h5"] .h5-header { position: sticky; top: 0; z-index: 5; background: var(--primary); color: #fff; padding: 14px 16px; font-weight: 600; display: flex; justify-content: space-between; align-items: center; }
body[data-mode="h5"] .h5-view { padding: 14px 14px 78px; }
body[data-mode="h5"] .tabbar { position: fixed; bottom: 0; left: 0; right: 0; height: 62px; background: #fff; border-top: 1px solid var(--line); display: flex; z-index: 5; padding-bottom: env(safe-area-inset-bottom); }
body[data-mode="h5"] .tabbar button { flex: 1; border: 0; background: transparent; color: var(--muted); font-size: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
body[data-mode="h5"] .tabbar button.active { color: var(--primary); font-weight: 600; }
body[data-mode="h5"] .tabbar .ico { font-size: 19px; line-height: 1; }

/* ---------- 通用组件 ---------- */
.page-title { font-size: 18px; font-weight: 650; margin: 0 0 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin-bottom: 14px; }
.grid { display: grid; gap: 14px; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat { text-align: center; }
.stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.stat .label { color: var(--muted); font-size: 12px; margin-top: 4px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn { border: 1px solid var(--primary); background: var(--primary); color: #fff; border-radius: 8px; padding: 8px 16px; font-size: 14px; }
.btn:hover { background: var(--primary-dark); }
.btn.ghost { background: #fff; color: var(--primary); }
.btn.small { padding: 5px 10px; font-size: 12px; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.success { background: var(--success); border-color: var(--success); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text); }
.field textarea { min-height: 130px; font-family: ui-monospace, Consolas, monospace; }
.hint { color: var(--muted); font-size: 12px; margin-top: 4px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 10px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13px; vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: #f8fafc; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.pending { background: #fef3c7; color: #92400e; }
.badge.approved { background: #dcfce7; color: #166534; }
.badge.rejected { background: #fee2e2; color: #991b1b; }
.badge.withdrawn { background: #e5e7eb; color: #374151; }
.badge.info { background: #e0f2fe; color: #075985; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; }
.muted { color: var(--muted); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { border-left: 2px solid var(--line); padding: 0 0 12px 14px; position: relative; }
.timeline li::before { content: ''; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }
.toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; z-index: 99; font-size: 13px; }

/* ---------- 登录遮罩 ---------- */
.overlay { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.login-box { background: #fff; border-radius: 14px; padding: 28px; width: 360px; max-width: 92vw; box-shadow: 0 20px 60px rgba(0,0,0,.18); }
.login-box h2 { margin: 0 0 6px; font-size: 20px; }
.login-box p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.user-btn { display: flex; justify-content: space-between; align-items: center; width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; text-align: left; }
.user-btn:hover { border-color: var(--primary); background: #f8fbff; }
.user-btn small { color: var(--muted); }

/* ---------- 管理后台 ---------- */
.admin-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.admin-tabs button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 14px; }
.admin-tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

body[data-mode="h5"] .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
body[data-mode="h5"] .grid.cols-2 { grid-template-columns: 1fr; }
body[data-mode="h5"] table { font-size: 12px; }
body[data-mode="h5"] th, body[data-mode="h5"] td { padding: 7px 6px; }
body[data-mode="h5"] .h5-logout { border: 1px solid rgba(255,255,255,.7); background: transparent; color: #fff; border-radius: 6px; padding: 2px 8px; font-size: 12px; }
.readonly-dept { background: #f8fbff; border-left: 4px solid var(--primary); }
.readonly-dept .hint { margin-left: 10px; }
.field input[readonly], .field select[readonly] { background: #f1f5f9; color: var(--muted); cursor: not-allowed; }

/* ---------- 可视化审批流程设计器 ---------- */
.flow-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.flow-canvas { border: 1px dashed var(--line); border-radius: 10px; background: #f8fafc; padding: 12px; min-height: 90px; }
.flow-node { background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--primary); border-radius: 9px; padding: 10px 12px; margin-bottom: 10px; cursor: grab; box-shadow: 0 1px 4px rgba(15,23,42,.05); }
.flow-node:last-child { margin-bottom: 0; }
.flow-node.dragging { opacity: .45; }
.flow-node.drop-before { box-shadow: 0 -3px 0 var(--primary); }
.flow-node.drop-after { box-shadow: 0 3px 0 var(--primary); }
.flow-node[data-type="cc"] { border-left-color: var(--warn); }
.flow-node-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.flow-grip { color: var(--muted); font-size: 17px; line-height: 1; user-select: none; }
.flow-seq { background: #e8f0fe; color: var(--primary); border-radius: 999px; min-width: 22px; height: 22px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
.flow-node-title { flex: 1; font-weight: 600; }
.flow-node-type { font-size: 11px; color: var(--muted); background: #f1f5f9; border-radius: 4px; padding: 2px 6px; }
.flow-node-ops { display: flex; gap: 4px; }
.flow-node-ops button { border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 2px 7px; font-size: 12px; color: var(--text); }
.flow-node-ops button:hover { border-color: var(--primary); color: var(--primary); }
.flow-node-body { display: grid; grid-template-columns: 90px 1fr; gap: 6px 10px; align-items: center; font-size: 12px; }
.flow-node-body label { color: var(--muted); }
.flow-node-body input, .flow-node-body select { border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12px; background: #fff; color: var(--text); min-width: 0; }
.flow-cond { display: flex; gap: 6px; align-items: center; }
.flow-cond select, .flow-cond input { flex: 1; }
.flow-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 18px 0; }
.flow-json summary { cursor: pointer; color: var(--muted); font-size: 12px; padding: 6px 0; }
.flow-json textarea { min-height: 90px; }

/* ---------- 侧栏菜单分组 ---------- */
.nav-group { font-size: 11px; color: var(--muted); letter-spacing: 1px; margin: 18px 8px 6px; font-weight: 600; }

/* ---------- 发起页二级页面 ---------- */
.apply-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 14px; }
.apply-tab { flex: 0 0 auto; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 9px 14px; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); white-space: nowrap; }
.apply-tab:hover { border-color: var(--primary); }
.apply-tab.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 600; }
.apply-tab-ico { display: inline-flex; width: 26px; height: 26px; border-radius: 7px; background: #e8f0fe; color: var(--primary); align-items: center; justify-content: center; font-size: 13px; font-weight: 700; }
.apply-tab.active .apply-tab-ico { background: rgba(255,255,255,.22); color: #fff; }
.apply-tab-tag { font-size: 10px; background: #fef3c7; color: #92400e; border-radius: 4px; padding: 1px 5px; }
.apply-tab.active .apply-tab-tag { background: rgba(255,255,255,.25); color: #fff; }
body[data-mode="h5"] .apply-tab { padding: 8px 12px; }

.placeholder-card { text-align: center; padding: 42px 18px; }
.placeholder-ico { width: 60px; height: 60px; margin: 0 auto; border-radius: 16px; background: #e8f0fe; color: var(--primary); font-size: 26px; font-weight: 700; display: flex; align-items: center; justify-content: center; }

.req { color: var(--danger); font-style: normal; }
.hint.warn { color: var(--warn); font-weight: 600; }
.warn { color: var(--danger); }
.balance-hint { padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #f8fbff; font-size: 13px; }
.duration-box { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: #f8fafc; display: flex; align-items: baseline; gap: 10px; }
.duration-num { font-size: 22px; color: var(--primary); }
.attach-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.attach-item { display: flex; align-items: center; gap: 10px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; background: #fafbfc; font-size: 13px; }
.attach-item a { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 16px; font-size: 13px; }
.detail-grid > div { display: flex; flex-direction: column; gap: 3px; }
.detail-grid small { color: var(--muted); font-size: 11px; }
.reason-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; white-space: pre-wrap; }
body[data-mode="h5"] .detail-grid { grid-template-columns: 1fr; }

/* ---------- 工作时长 / 功能权限 ---------- */
.wt-table input[type="time"] { border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 13px; }
.wt-table th, .wt-table td { vertical-align: middle; }
.wd-check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.perm-table th, .perm-table td { text-align: center; }
.perm-table th:first-child, .perm-table td:first-child, .perm-table td:nth-child(2) { text-align: left; }
.perm-table input[type="checkbox"] { width: 17px; height: 17px; cursor: pointer; }
.wt-table input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ---------- 组织架构 / 多部门会签 ---------- */
.org-tree { border: 1px solid var(--line); border-radius: 8px; padding: 12px; background: #fbfcfe; }
.org-node { padding: 4px 0; }
.org-dept { font-size: 13px; padding: 4px 0; }
.org-dept .muted { font-size: 11px; font-weight: 400; }
.org-members { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 8px; }
.org-person { display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: #fff; border-radius: 16px; padding: 3px 9px; font-size: 12px; }
.org-person small { font-size: 10px; }
.org-lv { border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 600; }
.lv-gm { background: #fee2e2; color: #991b1b; }
.lv-vg { background: #fed7aa; color: #9a3412; }
.lv-dh { background: #dbeafe; color: #1e40af; }
.lv-sup { background: #dcfce7; color: #166534; }
.lv-emp { background: #f1f5f9; color: #475569; }
.org-table th, .org-table td { vertical-align: middle; font-size: 12px; }
.org-table select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 12px; background: #fff; color: var(--text); max-width: 190px; }
.sign-depts { grid-column: 2; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.sign-dept { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; white-space: nowrap; }
.sign-dept input { width: 14px; height: 14px; }
.flow-node[data-type="parallel"] { border-left-color: #7c3aed; }

/* ---------- 条件分支流程图 ---------- */
.flow-chart { border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 10px 4px; margin-bottom: 10px; overflow: auto; }
.flow-chart-title { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.flow-svg { width: 100%; min-width: 720px; height: auto; display: block; }
.flow-node[data-type="branch"] { border-left-color: #f59e0b; background: #fffdf8; }
.flow-branch-body { display: block; }
.flow-branch-body > label { display: inline-block; width: 78px; color: var(--muted); }
.flow-branch-body > input { width: calc(100% - 92px); border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12px; background: #fff; color: var(--text); }
.flow-hint { font-size: 11px; color: var(--muted); margin: 6px 0; line-height: 1.5; }
.flow-branches { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.flow-branch-lane { border: 1px dashed #f59e0b; border-left: 4px solid #f59e0b; border-radius: 8px; padding: 8px; background: #fffdf8; }
.flow-branch-head { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.flow-branch-head > input[data-bprop="name"] { flex: 1; min-width: 130px; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12px; background: #fff; color: var(--text); }
.flow-branch-head .flow-cond { flex: 2; min-width: 260px; }
.flow-diamond { color: #d97706; font-size: 16px; line-height: 1; }
.flow-branch-nodes { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.flow-branch-nodes > .btn { align-self: flex-start; }
.flow-mini-node { border: 1px solid var(--line); border-left: 3px solid #3b82f6; border-radius: 7px; padding: 6px 8px; background: #fff; }
.flow-mini-node[data-type="cc"] { border-left-color: #f59e0b; }
.flow-mini-node[data-type="parallel"] { border-left-color: #7c3aed; }
.flow-mini-head { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.flow-mini-seq { background: #e8f0fe; color: var(--primary); border-radius: 999px; min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.flow-mini-body { display: grid; grid-template-columns: 54px 1fr; gap: 4px 8px; margin-top: 6px; font-size: 11px; align-items: center; }
.flow-mini-body label { color: var(--muted); }
.flow-mini-body input, .flow-mini-body select { border: 1px solid var(--line); border-radius: 6px; padding: 4px 6px; font-size: 11px; background: #fff; color: var(--text); min-width: 0; }
.flow-mini-body .sign-depts { grid-column: 2; }

/* 企业微信集成 */
.wecom-login { padding: 8px 0 12px; margin-bottom: 12px; border-bottom: 1px dashed var(--line); }
.wecom-login input { min-width: 0; }
.wecom-form label { display: block; color: var(--muted); font-size: 12px; margin: 8px 0 4px; }
.wecom-form input[type="text"], .wecom-form input:not([type]) { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; font-size: 13px; background: #fff; color: var(--text); }
.wecom-form .wd-check { margin-top: 10px; color: var(--text); font-size: 13px; }

/* 附件在线预览 / 下载 */
.attach-item { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.attach-item:last-child { border-bottom: 0; }
.attach-item .attach-name { font-weight: 600; max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-box { width: 880px; max-width: 96vw; height: 86vh; background: #fff; border-radius: 12px; display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.preview-head b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-frame { flex: 1; width: 100%; border: 0; background: #fff; }

/* 审批退回 / 沟通 */
.action-panel { margin-top: 10px; padding: 12px; border: 1px dashed var(--line); border-radius: 8px; background: #f8fafc; }
.action-panel[hidden] { display: none; }
.talk-box { background: #f8fafc; border-left: 3px solid #94a3b8; border-radius: 6px; padding: 7px 10px; margin: 5px 0; white-space: pre-wrap; word-break: break-word; }
.talk-box.reply { border-left-color: var(--success); }
.consult-card { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; background: #fff; }
.consult-card .field { margin-top: 8px; }
.badge.returned { background: #fef3c7; color: #92400e; }

/* 工作台最新动态：公开发文/通知 + 自身相关审批单 */
.feed-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.feed-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 8px; border-bottom: 1px dashed var(--line); cursor: pointer; border-radius: 8px; }
.feed-item:last-child { border-bottom: 0; }
.feed-item:hover { background: #f8fafc; }
.feed-item b { font-weight: 600; }
.feed-tag { flex-shrink: 0; font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 600; }
.feed-tag.ann { background: #e0e7ff; color: #3730a3; }
.feed-tag.app { background: #dcfce7; color: #166534; }
.feed-scope { font-size: 12px; color: var(--muted); background: #f1f5f9; padding: 2px 8px; border-radius: 6px; }
.feed-summary { flex-basis: 100%; padding-left: 2px; font-size: 12px; }
.feed-item .muted { font-size: 12px; }
body[data-mode="h5"] .feed-item { gap: 6px; }
