:root {
  --bg: #f5f6f8; --card: #fff; --line: #e3e6ea; --text: #1f2937; --muted: #6b7280;
  --primary: #1f5fbf; --primary-2: #e8f0fc; --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --warn-bg: #fff7e6;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: -apple-system, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
header.top { background: #17233d; color: #fff; padding: 0 24px; display: flex; align-items: center; height: 52px; gap: 24px; }
header.top .brand { font-weight: 600; font-size: 16px; color: #fff; }
header.top nav a { color: #cbd5e1; margin-right: 18px; }
header.top nav a.active, header.top nav a:hover { color: #fff; text-decoration: none; }
main { max-width: 1280px; margin: 0 auto; padding: 22px 24px 60px; }
h1 { font-size: 20px; margin: 0 0 14px; }
h2 { font-size: 16px; margin: 22px 0 10px; }
.flash { background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46; padding: 8px 12px; border-radius: 6px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.stats { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 12px; }
.stat { background: var(--primary-2); border-radius: 8px; padding: 10px 14px; min-width: 150px; }
.stat .k { color: var(--muted); font-size: 12px; }
.stat .v { font-size: 18px; font-weight: 600; margin-top: 2px; }
.stat.hl { background: var(--warn-bg); }
.stat.hl .v { color: var(--warn); }
table { width: 100%; border-collapse: collapse; background: #fff; }
th, td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: middle; }
th { background: #f1f4f8; font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 600; background: #fff9e8; }
.tbl-wrap { overflow-x: auto; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 12px; white-space: nowrap; }
.b-paid { background: #dcfce7; color: var(--ok); }
.b-open { background: #fee2e2; color: var(--bad); }
.b-part { background: #fef3c7; color: var(--warn); }
.b-pend { background: #e5e7eb; color: #374151; }
.btn { display: inline-block; padding: 6px 12px; border-radius: 6px; border: 1px solid var(--primary); background: var(--primary); color: #fff; cursor: pointer; font-size: 13px; line-height: 1.3; }
.btn:hover { text-decoration: none; opacity: .92; }
.btn.secondary { background: #fff; color: var(--primary); }
.btn.danger { background: #fff; color: var(--bad); border-color: #fca5a5; }
.btn.sm { padding: 3px 8px; font-size: 12px; white-space: nowrap; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar .spacer { flex: 1; }
form.inline { display: inline; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 3px; }
input[type=text], input[type=number], input[type=date], input[type=password], input[type=month], select, textarea {
  width: 100%; padding: 6px 8px; border: 1px solid #cbd2da; border-radius: 6px; font-size: 14px; font-family: inherit; background: #fff; }
input.cell { width: 100px; padding: 4px 6px; text-align: right; }
input.cell-txt { width: 150px; padding: 4px 6px; }
.form-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--text); }
.check input { width: auto; }
.muted { color: var(--muted); font-size: 12px; }
.help { color: var(--muted); font-size: 12px; margin-top: 3px; }
.actions { margin-top: 16px; display: flex; gap: 8px; align-items: center; }
.empty { color: var(--muted); padding: 20px; text-align: center; }
.mini-form { display: flex; gap: 6px; align-items: flex-end; flex-wrap: wrap; }
.mini-form > div { min-width: 120px; }
/* 工资条 */
.slip { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 18px 22px; margin-bottom: 18px; max-width: 720px; }
.slip h3 { margin: 0 0 4px; font-size: 16px; }
.slip .sub { color: var(--muted); margin-bottom: 10px; }
.slip table td:nth-child(2) { text-align: right; width: 140px; font-variant-numeric: tabular-nums; }
.slip tr.hl td { background: #fff9e8; font-weight: 600; }
.slip .sign { margin-top: 14px; color: var(--muted); }
@media print {
  header.top, .no-print, .flash { display: none !important; }
  body { background: #fff; }
  main { max-width: none; padding: 0; }
  .slip { page-break-after: always; border: none; max-width: none; margin: 0; padding: 10mm 0; }
  .slip:last-child { page-break-after: auto; }
}
header.top nav a { font-size: 15px; }

/* 报销汇总矩阵 */
table.matrix { table-layout: fixed; border: 1px solid var(--line); font-size: 15px; }
table.matrix th, table.matrix td { padding: 12px 14px; border: 1px solid var(--line); }
table.matrix th { text-align: center; }
table.matrix th.num { text-align: right; }
table.matrix td.cat { font-weight: 500; }
table.matrix td.num { font-variant-numeric: tabular-nums; }
table.matrix td.blank { color: #c4c9d0; text-align: center; }
table.matrix td.rowtotal { font-weight: 600; background: #f8fafc; }
table.matrix td.note { color: var(--muted); font-size: 13px; line-height: 1.5; white-space: normal; word-break: break-all; }
table.matrix tr:nth-child(even) td { background: #fafbfc; }
table.matrix tr:nth-child(even) td.rowtotal { background: #f1f4f8; }
table.matrix tr.total td { background: #fff4d6; font-weight: 700; font-size: 16px; border-top: 2px solid #e0b64a; }
/* 工资表：高级列默认隐藏 */
table.payroll .adv { display: none; }
body.show-adv table.payroll .adv { display: table-cell; }
table.payroll th, table.payroll td { padding: 6px 6px; }
details summary { cursor: pointer; }
/* 编辑卡片 */
dialog.edit-dlg { border: 1px solid var(--line); border-radius: 12px; padding: 20px 24px; width: 760px; max-width: 95vw; box-shadow: 0 12px 40px rgba(0,0,0,.18); }
dialog.edit-dlg::backdrop { background: rgba(15,23,42,.45); }
.dlg-sec { font-weight: 600; margin: 14px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.dlg-sec:first-of-type { margin-top: 0; }
table.payroll th, table.payroll td { padding: 8px 8px; }
form.inline.mini-form { display: flex; align-items: center; gap: 6px; }
form.inline.mini-form > div { min-width: 0; }

/* 只读用户：隐藏所有表单和编辑入口（服务端另有拦截） */
body.viewer form:not(.viewer-ok) { display: none !important; }
body.viewer .edit-only, body.viewer .btn.danger { display: none !important; }
header.top nav { display: flex; align-items: center; flex: 1; }
/* 审批 */
.card.approval { padding: 10px 16px; border-left: 4px solid #cbd5e1; }
.card.approval.pending { border-left-color: #f59e0b; background: #fffbeb; }
.card.approval.approved { border-left-color: #16a34a; background: #f0fdf4; }
.card.approval.returned { border-left-color: #dc2626; background: #fef2f2; }
.ap-badge { display:inline-block; padding: 3px 10px; border-radius: 12px; font-weight: 600; font-size: 13px; background: #e5e7eb; color: #374151; }
.ap-badge.pending { background: #fef3c7; color: #b45309; }
.ap-badge.approved { background: #dcfce7; color: #15803d; }
.ap-badge.returned { background: #fee2e2; color: #b91c1c; }
body.locked .edit-only, body.locked form.lock-hide { display: none !important; }
.pending-banner { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; }

/* ===== 视觉刷新 ===== */
.card { border-radius: 12px; box-shadow: 0 1px 3px rgba(16,24,40,.05); }
th { font-size: 12px; color: var(--muted); letter-spacing: .02em; background: #f8fafc; }
tr:hover td { background: #fafbfd; }
tr.total:hover td { background: #fff9e8; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 16px; }
.page-head h1 { margin: 0 0 4px; font-size: 22px; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-head h2 { margin: 0; font-size: 15px; }
.card-head a { font-size: 13px; }
/* 待办 */
.todo { background: #fff; border: 1px solid #fcd34d; border-left: 5px solid #f59e0b; border-radius: 12px; padding: 12px 18px; margin-bottom: 18px; box-shadow: 0 2px 8px rgba(245,158,11,.12); }
.todo-head { display: flex; align-items: center; gap: 10px; font-size: 15px; margin-bottom: 6px; }
.todo-icon { width: 22px; height: 22px; border-radius: 50%; background: #f59e0b; color: #fff; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; }
.todo-row { display: flex; align-items: center; gap: 12px; padding: 9px 0; border-top: 1px dashed #fde68a; }
.todo-title { font-weight: 600; font-size: 15px; }
/* KPI */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi { display: block; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px; color: inherit; box-shadow: 0 1px 3px rgba(16,24,40,.05); border-top: 3px solid var(--primary); }
.kpi:hover { text-decoration: none; box-shadow: 0 4px 14px rgba(16,24,40,.08); }
.kpi.warn { border-top-color: #f59e0b; }
.kpi .k { color: var(--muted); font-size: 12px; }
.kpi .v { font-size: 24px; font-weight: 700; margin: 4px 0 2px; letter-spacing: -.01em; }
.kpi.warn .v { color: var(--warn); }
.kpi .s { color: var(--muted); font-size: 12px; }
@media (max-width: 900px) { .kpis { grid-template-columns: repeat(2, 1fr); } .grid-2 { grid-template-columns: 1fr; } }
