/* ==========================================================================
   KPS 薪资核算系统 · 全局样式
   Tailwind 预编译样式已本地化（/assets/vendor），局域网无外网时同样可用
   ========================================================================== */
@import url('../vendor/tailwind.min.css');

:root {
  --primary: #2563EB;
  --primary-dark: #1D4ED8;
  --primary-light: #3B82F6;
  --primary-50: #EFF6FF;
  --bg: #F5F7FA;
  --surface: #FFFFFF;
  --ink: #1F2937;
  --muted: #6B7280;
  --dark: #0F172A;
  --dark-2: #1E293B;
  --line: #E5E7EB;
  --ok: #16A34A;
  --danger: #DC2626;
  --warn: #D97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .05);
  --shadow: 0 4px 12px rgba(15, 23, 42, .08);
  --shadow-lg: 0 18px 40px rgba(15, 23, 42, .14);
  --t: 160ms cubic-bezier(.4, 0, .2, 1);
  --sidebar-w: 236px;
  --topbar-h: 62px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', 'Hiragino Sans GB', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0; font-weight: 600; }
h1 { font-size: 24px; letter-spacing: -.2px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; font-weight: 500; }

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ------------------------------ 登录页 ------------------------------ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  background: var(--surface);
  position: relative;
  overflow: hidden;
}

.login-brand {
  position: relative;
  background: linear-gradient(150deg, #0F172A 0%, #1E3A8A 55%, #2563EB 100%);
  color: #fff;
  padding: 64px 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.login-brand::after {
  content: '';
  position: absolute;
  width: 460px; height: 460px;
  right: -140px; top: -120px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(59, 130, 246, .55), transparent 65%);
  filter: blur(10px);
  animation: float 14s ease-in-out infinite;
}

.login-brand::before {
  content: '';
  position: absolute;
  width: 320px; height: 320px;
  left: -110px; bottom: -90px;
  border-radius: 50%;
  background: radial-gradient(circle at 60% 40%, rgba(14, 165, 233, .35), transparent 65%);
  filter: blur(8px);
  animation: float 18s ease-in-out infinite reverse;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(26px, -26px); }
}

.login-logo {
  display: inline-flex; align-items: center; gap: 12px;
  font-size: 15px; font-weight: 600; letter-spacing: 3px;
}
.login-logo .mark {
  width: 40px; height: 40px; border-radius: 10px;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .28);
  display: grid; place-items: center; font-size: 19px;
  backdrop-filter: blur(6px);
}
.login-title { font-size: 34px; font-weight: 600; line-height: 1.28; }
.login-desc { color: rgba(255, 255, 255, .74); max-width: 420px; font-size: 15px; }
.login-points { display: grid; gap: 12px; margin-top: 8px; }
.login-points li {
  list-style: none; display: flex; align-items: center; gap: 10px;
  color: rgba(255, 255, 255, .84); font-size: 13.5px;
}
.login-points li::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: #93C5FD; box-shadow: 0 0 0 4px rgba(147, 197, 253, .18);
}

.login-panel {
  display: flex; align-items: center; justify-content: center;
  padding: 48px 40px;
}
.login-box { width: 100%; max-width: 372px; display: grid; gap: 18px; }
.login-box h1 { font-size: 25px; }
.login-hint { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
}

/* ------------------------------ 主框架 ------------------------------ */
.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: linear-gradient(180deg, var(--dark) 0%, #111E3A 100%);
  color: #C7D2E4;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  z-index: 30;
}
.sidebar-head {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.sidebar-head .mark {
  width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; font-size: 15px;
}
.sidebar-head b { color: #fff; font-size: 15px; letter-spacing: .5px; }
.sidebar-head small { display: block; color: #64748B; font-size: 11px; letter-spacing: 2px; }

.nav { padding: 14px 12px; overflow-y: auto; flex: 1; }
.nav-group { margin: 16px 0 6px; padding: 0 10px; font-size: 11px; letter-spacing: 2px; color: #64748B; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 9px;
  font-size: 13.5px; color: #B6C2D6; margin-bottom: 2px;
  transition: background var(--t), color var(--t), transform var(--t);
}
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; transform: translateX(2px); }
.nav a.active {
  background: linear-gradient(90deg, rgba(37, 99, 235, .95), rgba(37, 99, 235, .65));
  color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .32);
}
.sidebar-foot {
  padding: 12px; border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 12px; color: #64748B; display: grid; gap: 6px;
}
.sidebar-foot a { color: #93C5FD; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-h);
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 20;
}
.topbar .crumb { color: var(--muted); font-size: 13px; }
.topbar .crumb b { color: var(--ink); font-weight: 600; font-size: 15px; }
.spacer { flex: 1; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 6px; border-radius: 999px;
  background: var(--primary-50); border: 1px solid #DBEAFE;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.user-chip small { display: block; color: var(--muted); font-size: 11px; }

.content { padding: 22px 24px 40px; }

/* ------------------------------ 组件 ------------------------------ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 15px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px;
}
.card-head h2 { font-size: 15.5px; }
.card-head p { margin: 2px 0 0; color: var(--muted); font-size: 12.5px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1200px) {
  .grid-5, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .grid-5, .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

.stat {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px;
  position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform var(--t), box-shadow var(--t);
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat::after {
  content: ''; position: absolute; right: -22px; top: -22px;
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--tint, rgba(37, 99, 235, .08));
}
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 25px; font-weight: 600; margin-top: 6px; letter-spacing: -.5px; position: relative; }
.stat .foot { font-size: 12px; color: var(--muted); margin-top: 4px; position: relative; }
.stat.ok { --tint: rgba(22, 163, 74, .1); }
.stat.warn { --tint: rgba(217, 119, 6, .12); }
.stat.danger { --tint: rgba(220, 38, 38, .1); }
.stat.info { --tint: rgba(37, 99, 235, .09); }

/* 紧凑汇总条：台账页顶部一行放下关键数字，不占大块面积 */
.sumbar {
  display: flex; flex-wrap: wrap; gap: 6px 0;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 6px;
  box-shadow: var(--shadow-sm);
}
.sumbar .item {
  flex: 1 1 0; min-width: 130px; text-align: center;
  padding: 2px 12px; position: relative;
}
.sumbar .item + .item::before {
  content: ''; position: absolute; left: 0; top: 8%; height: 84%;
  width: 1px; background: var(--line);
}
.sumbar .label { font-size: 12px; color: var(--muted); }
.sumbar .value { font-size: 17px; font-weight: 600; margin-top: 2px; letter-spacing: -.3px; }
.sumbar .foot { font-size: 11.5px; color: var(--muted); margin-top: 1px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 15px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink); cursor: pointer;
  transition: all var(--t); white-space: nowrap;
}
.btn:hover { border-color: #CBD5E1; background: #F8FAFC; transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  border-color: transparent; color: #fff;
  box-shadow: 0 6px 16px rgba(37, 99, 235, .28);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), var(--primary)); color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: #F1F5F9; color: var(--ink); }
.btn-danger { color: var(--danger); border-color: #FECACA; background: #FEF2F2; }
.btn-danger:hover { background: #FEE2E2; border-color: #FCA5A5; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }

/* 表单 */
.field { display: grid; gap: 5px; }
.field > label { font-size: 12.5px; color: var(--muted); font-weight: 500; }
.input, .select, textarea.input {
  width: 100%; padding: 8px 11px;
  border: 1px solid #D6DBE4; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--ink);
  transition: border-color var(--t), box-shadow var(--t);
}
.input:focus, .select:focus, textarea.input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}
.input:disabled, .select:disabled { background: #F8FAFC; color: var(--muted); }
textarea.input { min-height: 84px; resize: vertical; font-family: 'SFMono-Regular', Consolas, monospace; font-size: 13px; }
.input-inline { width: 110px; padding: 4px 8px; font-size: 13px; border-radius: 6px; border: 1px solid #D6DBE4; text-align: right; }
.input-inline:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 2px rgba(37, 99, 235, .16); }

.toolbar {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.toolbar .field { min-width: 150px; }
.toolbar .field.grow { flex: 1; min-width: 210px; }

/* 表格 */
.table-wrap { overflow: auto; max-height: 68vh; border-radius: 0 0 var(--radius) var(--radius); }
table.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.table thead th {
  position: sticky; top: 0; z-index: 2;
  background: #F8FAFC; color: #475569;
  font-weight: 600; font-size: 12.5px; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.table tbody td {
  padding: 9px 12px; border-bottom: 1px solid #F1F5F9; white-space: nowrap;
}
table.table tbody tr { transition: background var(--t); }
table.table tbody tr:nth-child(even) { background: #FCFDFE; }
table.table tbody tr:hover { background: var(--primary-50); }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table td.negative { color: var(--danger); font-weight: 600; }
table.table tr.leave td { color: #94A3B8; }
table.table .sticky-col {
  position: sticky; left: 0; background: inherit; z-index: 1;
}
table.table thead th.sticky-col { background: #F1F5F9; z-index: 3; }
table.table .warn-cell { background: #FEF3C7; }
/* 权限勾选矩阵 */
.perm-matrix {
  display: grid; gap: 10px; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px;
  max-height: 320px; overflow: auto; background: #FCFDFF;
}
.perm-mod { border-bottom: 1px dashed var(--line); padding-bottom: 8px; }
.perm-mod:last-child { border-bottom: none; padding-bottom: 0; }
.perm-mod-head { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 6px; }
.perm-items { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; padding-left: 22px; }
.perm-items label { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink); }
.perm-tools { display: flex; align-items: center; gap: 8px; margin-top: 6px; flex-wrap: wrap; }
@media (max-width: 760px) { .perm-items { grid-template-columns: 1fr 1fr; } }

/* 汇总报表的合计行 */
table.table tbody tr.total-row { background: #F1F5F9; font-weight: 600; }
table.table tbody tr.total-row:hover { background: #E7EEF8; }
table.table tbody tr.total-row td { border-top: 2px solid #94A3B8; }

.pager {
  display: flex; align-items: center; gap: 10px; justify-content: flex-end;
  padding: 12px 18px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px;
}

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px; font-size: 11.5px; font-weight: 500;
  border: 1px solid transparent;
}
.badge-ok { background: #ECFDF5; color: #15803D; border-color: #BBF7D0; }
.badge-warn { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.badge-danger { background: #FEF2F2; color: #B91C1C; border-color: #FECACA; }
.badge-info { background: var(--primary-50); color: var(--primary-dark); border-color: #BFDBFE; }
.badge-muted { background: #F1F5F9; color: var(--muted); border-color: #E2E8F0; }

/* 进度条 */
.progress { height: 7px; border-radius: 999px; background: #E2E8F0; overflow: hidden; }
.progress > i {
  display: block; height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--primary-light));
  transition: width 480ms cubic-bezier(.4, 0, .2, 1);
}
.progress.ok > i { background: linear-gradient(90deg, #16A34A, #4ADE80); }
.progress.warn > i { background: linear-gradient(90deg, #D97706, #FBBF24); }

/* Toast */
.toast-host {
  position: fixed; right: 22px; top: 20px; z-index: 999;
  display: grid; gap: 10px; width: 336px;
}
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 4px solid var(--primary);
  border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow-lg);
  animation: slideIn .22s cubic-bezier(.4, 0, .2, 1);
  display: flex; gap: 10px; align-items: flex-start;
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
.toast b { display: block; font-size: 13.5px; }
.toast span { color: var(--muted); font-size: 12.5px; }
@keyframes slideIn { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }

/* 弹窗 */
.modal-host {
  position: fixed; inset: 0; z-index: 900;
  background: rgba(15, 23, 42, .48); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; padding: 54px 20px; overflow: auto;
}
.modal-host.show { display: flex; }
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 640px; animation: pop .2s cubic-bezier(.4, 0, .2, 1);
}
.modal.wide { max-width: 1080px; }
@keyframes pop { from { opacity: 0; transform: translateY(-12px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-body { padding: 20px; max-height: 70vh; overflow: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }

/* 标签页 */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding: 0 18px; overflow-x: auto; }
.tabs button {
  padding: 11px 14px; border: none; background: transparent; cursor: pointer;
  color: var(--muted); font-size: 13.5px; border-bottom: 2px solid transparent;
  transition: color var(--t), border-color var(--t); white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 拖拽上传 */
.dropzone {
  border: 2px dashed #CBD5E1; border-radius: var(--radius);
  padding: 30px 20px; text-align: center; cursor: pointer;
  background: #FBFDFF; transition: all var(--t);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone .big { font-size: 32px; }

/* 步骤条 */
.steps { display: flex; align-items: center; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.step { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.step b {
  width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center;
  background: #E2E8F0; color: #64748B; font-size: 12px;
}
.step.active { color: var(--primary); font-weight: 600; }
.step.active b { background: var(--primary); color: #fff; }
.step.done b { background: var(--ok); color: #fff; }
.step-line { width: 26px; height: 1px; background: var(--line); }

/* 变量标签云 */
.var-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 7px; margin: 3px 4px 3px 0;
  background: var(--primary-50); color: var(--primary-dark);
  border: 1px solid #BFDBFE; cursor: pointer; font-size: 12px;
  transition: all var(--t);
}
.var-chip:hover { background: #DBEAFE; transform: translateY(-1px); }
.var-chip.param { background: #ECFDF5; color: #15803D; border-color: #BBF7D0; }
.var-chip.fn { background: #FEF3C7; color: #B45309; border-color: #FDE68A; font-family: Consolas, monospace; }

.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty .big { font-size: 40px; opacity: .45; margin-bottom: 8px; }

.note {
  background: var(--primary-50); border: 1px solid #BFDBFE; color: #1E40AF;
  border-radius: var(--radius-sm); padding: 10px 13px; font-size: 12.5px;
}
.note.warn { background: #FFFBEB; border-color: #FDE68A; color: #92400E; }
.note.danger { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

.mono { font-family: 'SFMono-Regular', Consolas, 'Courier New', monospace; font-size: 12.5px; }
.text-ok { color: var(--ok); }
.text-danger { color: var(--danger); }
.text-warn { color: var(--warn); }
.text-muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }
.scroll-x { overflow-x: auto; }
.dim { opacity: .72; }

.fade-in { animation: fade .3s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media print {
  .sidebar, .topbar, .no-print { display: none !important; }
  .content { padding: 0; }
}