:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line: #e6e8ec;
  --line-2: #f0f2f5;
  --text: #1f2430;
  --text-2: #5b6474;
  --muted: #8b93a3;
  --brand: #2563eb;
  --brand-weak: #eef4ff;
  --ok: #0f9d58;
  --ok-weak: #e9f7ef;
  --warn: #d97706;
  --warn-weak: #fef6e7;
  --danger: #dc2626;
  --danger-weak: #fdeceb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 "Microsoft YaHei", "PingFang SC", -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d5d9e0; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #bcc2cc; background-clip: content-box; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(1200px 600px at 20% 0%, #eaf1ff 0%, #f5f6f8 55%);
}
.login-card {
  width: 380px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 34px 32px; box-shadow: 0 12px 32px rgba(16,24,40,.08);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; letter-spacing: .5px; }
.login-card .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 24px; }
.login-card .field { margin-bottom: 14px; }
.login-card .hint { margin-top: 14px; font-size: 12px; color: var(--muted); line-height: 1.7; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.side {
  width: 208px; flex: 0 0 208px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 14px; border-bottom: 1px solid var(--line-2);
}
.brand .logo {
  width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff; font-weight: 700; font-size: 14px;
}
.brand .t1 { font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.brand .t2 { font-size: 11px; color: var(--muted); }

.nav { padding: 10px 10px; flex: 1; overflow: auto; }
.nav-group { font-size: 11px; color: var(--muted); padding: 12px 8px 6px; letter-spacing: .5px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 9px 10px; border-radius: 8px;
  color: var(--text-2); cursor: pointer; font-size: 13.5px; margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: #f3f5f8; color: var(--text); }
.nav-item.active { background: var(--brand-weak); color: var(--brand); font-weight: 600; }
.nav-item .ico { width: 16px; text-align: center; opacity: .9; }

.side-foot { border-top: 1px solid var(--line-2); padding: 12px 14px; font-size: 12px; color: var(--muted); }
.side-foot .who { color: var(--text); font-weight: 600; font-size: 12.5px; }
.side-foot .row { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 58px; background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.content { padding: 20px 22px 40px; }

/* ---------- 组件 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 13px;
  border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer;
  font-size: 13px; color: var(--text-2); white-space: nowrap; transition: .12s;
}
.btn:hover { border-color: #cfd6e0; background: #fafbfc; color: var(--text); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #1d4fd8; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn.ghost:hover { background: #f1f3f6; }
.btn.sm { height: 27px; padding: 0 10px; font-size: 12px; }
.btn.danger { color: var(--danger); border-color: #f3c6c2; background: #fff; }
.btn.danger:hover { background: var(--danger-weak); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .select {
  height: 32px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; outline: none; font-size: 13px; width: 100%;
}
.input:focus, .select:focus { border-color: #9dbcfb; box-shadow: 0 0 0 3px rgba(37,99,235,.10); }
.input.sm, .select.sm { height: 27px; font-size: 12px; padding: 0 8px; }

/* 密码栏位小眼睛 */
.pwd-wrap { position: relative; }
.pwd-wrap .input { padding-right: 32px; }
.pwd-eye {
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  font-size: 14px; line-height: 1; opacity: .5; text-decoration: none;
  user-select: none; cursor: pointer;
}
.pwd-eye:hover { opacity: 1; }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 16px; overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line-2);
}
.panel-head h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.panel-head .spacer { flex: 1; }
.panel-body { padding: 16px; }
.panel-body.flush { padding: 0; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.kpi .lbl { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .val { font-size: 23px; font-weight: 650; margin-top: 6px; letter-spacing: -.3px; font-variant-numeric: tabular-nums; }
.kpi .val small { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.kpi .sub { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line-2); white-space: nowrap; }
th {
  font-weight: 600; font-size: 12px; color: var(--text-2); background: #fafbfc;
  position: sticky; top: 0; z-index: 2;
}
tbody tr:hover { background: #fbfcfd; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.tbl-wrap { overflow: auto; max-height: calc(100vh - 260px); }

.tag {
  display: inline-flex; align-items: center; gap: 4px; height: 21px; padding: 0 8px;
  border-radius: 6px; font-size: 11.5px; background: #f1f3f6; color: var(--text-2); white-space: nowrap;
}
.tag.ok { background: var(--ok-weak); color: var(--ok); }
.tag.warn { background: var(--warn-weak); color: var(--warn); }
.tag.danger { background: var(--danger-weak); color: var(--danger); }
.tag.brand { background: var(--brand-weak); color: var(--brand); }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-2); padding: 0 16px; }
.tab {
  padding: 10px 14px; font-size: 13px; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.toolbar .grow { flex: 1; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; color: var(--text-2); margin-bottom: 5px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0 14px; }

.empty { padding: 46px 0; text-align: center; color: var(--muted); font-size: 13px; }
.empty .big { font-size: 26px; margin-bottom: 8px; opacity: .5; }

/* 抽屉 / 弹窗 */
.mask {
  position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 100;
  display: flex; justify-content: flex-end; animation: fade .15s;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
.drawer {
  width: 560px; max-width: 94vw; background: var(--panel); height: 100%;
  display: flex; flex-direction: column; box-shadow: -8px 0 24px rgba(16,24,40,.12);
  animation: slide .18s ease-out;
}
@keyframes slide { from { transform: translateX(20px) } to { transform: none } }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.drawer-head h3 { margin: 0; font-size: 15px; }
.drawer-body { padding: 18px 20px; overflow: auto; flex: 1; }
.drawer-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); display: flex; justify-content: flex-end; gap: 8px; }

.modal-wrap { position: fixed; inset: 0; background: rgba(17,24,39,.35); z-index: 110; display: grid; place-items: center; }
.modal { width: 460px; max-width: 92vw; background: #fff; border-radius: 12px; box-shadow: 0 18px 40px rgba(16,24,40,.18); }
.modal .drawer-head { border-bottom: 1px solid var(--line-2); }
.modal .drawer-foot { border-top: 1px solid var(--line-2); }

/* 图表 */
.chart { width: 100%; height: 190px; }
.chart-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); padding: 0 4px; }
/* 分析看板折线图：宽度完全跟随容器，高度固定，禁止撑破面板 */
.board-chart { width: 100%; max-width: 100%; overflow: hidden; }
.board-chart svg { display: block; max-width: 100%; }
.panel, .panel-body { min-width: 0; }
.content > [style*="grid-template-columns"] > * { min-width: 0; }

/* 提示 */
.toast-host { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #1f2937; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 13px;
  box-shadow: 0 8px 20px rgba(16,24,40,.22); animation: drop .18s;
}
.toast.err { background: #b91c1c; }
.toast.ok { background: #047857; }
@keyframes drop { from { opacity: 0; transform: translateY(-8px) } to { opacity: 1; transform: none } }

/* 日历 */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 11.5px; color: var(--muted); padding: 4px 0; }
.cal-day {
  min-height: 54px; border: 1px solid var(--line-2); border-radius: 8px; padding: 5px 7px;
  font-size: 12px; cursor: pointer; background: #fff; position: relative;
}
.cal-day:hover { border-color: #b9cdf7; }
.cal-day .d { font-weight: 600; color: var(--text-2); }
.cal-day.rest { background: #fafbfc; }
.cal-day.rest .d { color: var(--muted); }
.cal-day.holiday { background: #fdf2f2; border-color: #f6d5d2; }
.cal-day.holiday .d { color: var(--danger); }
.cal-day.makeup { background: #eef4ff; border-color: #d3e0fb; }
.cal-day .nm { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 12.5px; }
.bar-row .lb { width: 84px; color: var(--text-2); flex: 0 0 84px; }
.bar-track { flex: 1; height: 20px; background: #f3f5f8; border-radius: 5px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg,#60a5fa,#2563eb); }
.bar-row .vl { width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }

.hintline { font-size: 12px; color: var(--muted); line-height: 1.8; }
.divider { height: 1px; background: var(--line-2); margin: 14px 0; }
.scroll-x { overflow-x: auto; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }

/* 表单栅格（参数区） */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0 16px; }
.form-grid .field { margin-bottom: 10px; }

/* 行内开关 */
.switch { display: inline-flex; align-items: center; cursor: pointer; }
.switch input {
  appearance: none; -webkit-appearance: none; width: 34px; height: 19px; border-radius: 999px;
  background: #d7dce3; position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: 0 0 34px;
}
.switch input::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 15px; height: 15px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 2px rgba(16,24,40,.2); transition: transform .15s;
}
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(15px); }

/* 文字链接 */
.lnk { color: var(--brand); font-size: 12.5px; text-decoration: none; }
.lnk:hover { text-decoration: underline; }
.lnk.danger { color: var(--danger); }
.lnk.muted { color: var(--muted); }

/* 薪资计算公式页 */
.chip-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; font-size: 11.5px; color: var(--muted); }
.chip code { color: var(--brand); font-weight: 600; }
.chip.lnk { cursor: pointer; user-select: none; }
.chip.lnk:hover { border-color: var(--brand); background: var(--brand-weak, #eef4ff); }
textarea.input { height: auto; min-height: 56px; padding: 8px 10px; line-height: 1.5; resize: vertical;
  font-family: Consolas, Menlo, monospace; font-size: 12.5px; }
td.src { font-size: 11.5px; color: var(--muted); max-width: 300px; line-height: 1.45; }
td.ops { white-space: nowrap; }
td.ops .btn { margin-right: 4px; }

/* 表格内输入框自适应 */
td .input, td .select { width: 100%; min-width: 60px; }
td .input[style*="width"], td .select[style*="width"] { width: auto; }

/* 期间关闭提示条 */
.lockbar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 9px 14px; margin-bottom: 14px; border-radius: 8px;
  background: #fff7e6; border: 1px solid #ffd59e; color: #8a5a00; font-size: 12.5px;
}

/* ===== 考勤工作台：滚动标签 / 汇总矩阵 / 上传区 ===== */
.scroll-tabs { overflow-x: auto; flex-wrap: nowrap; scrollbar-width: thin; }
.scroll-tabs .tab { white-space: nowrap; flex: 0 0 auto; }

.mx-wrap { overflow: auto; max-height: 62vh; }
.mx-table { border-collapse: separate; border-spacing: 0; font-size: 11.5px; }
.mx-table th, .mx-table td { height: 26px; padding: 0; border-bottom: 1px solid var(--line-2); text-align: center; white-space: nowrap; }
.mx-table thead th { position: sticky; top: 0; z-index: 3; background: var(--bg-2, #f7f8fa); color: var(--muted); font-size: 10.5px; font-weight: 600; padding: 4px 2px; }
.mx-table thead th.rest { background: #faf7f0; }
.mx-table td.rest { background: #faf9f6; }
.mx-table .nm, .mx-table thead .nm { position: sticky; left: 0; z-index: 4; background: var(--bg-1, #fff); text-align: left; padding: 0 8px; min-width: 76px; box-shadow: 1px 0 0 var(--line-2); }
.mx-table .dp, .mx-table thead .dp { position: sticky; left: 76px; z-index: 4; background: var(--bg-1, #fff); text-align: left; padding: 0 8px; min-width: 88px; box-shadow: 1px 0 0 var(--line-2); font-size: 10.5px; color: var(--muted); }
.mx-table .it, .mx-table thead .it { position: sticky; left: 164px; z-index: 4; background: var(--bg-1, #fff); padding: 0 4px; min-width: 66px; box-shadow: 1px 0 0 var(--line-2); font-size: 10.5px; color: var(--muted); }
.mx-table thead .nm, .mx-table thead .dp, .mx-table thead .it { z-index: 5; background: var(--bg-2, #f7f8fa); }
.mx-table td.day { width: 24px; min-width: 24px; cursor: pointer; }
.mx-table td.sum, .mx-table th.sum { min-width: 46px; background: var(--bg-2, #fcfcfd); font-weight: 600; }
.mx-table tr:hover td.day { background: #eef6ff; }
/* 每人三行：打卡 / 出勤h / 加班h */
.mx-table tr.sub td { height: 20px; font-size: 10.5px; color: #6b7a90; }
/* 记账凭证明细：摘要/科目名称靠左，金额靠右 */
.vch-table th, .vch-table td { text-align: left; height: auto; padding: 6px 10px; white-space: normal; }
.vch-table th.num, .vch-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.mx-table tr.sub td.day { cursor: default; background: #fcfcfd; }
.mx-table tr.sub td.day.rest { background: #faf9f6; }
.mx-table tr.sub:hover td.day { background: #fcfcfd; }
.mx-table td.it.lbl { font-weight: 600; color: #55637a; }
.mx-table .wh-h { color: #47586e; font-weight: 500; }
.mx-table .ot-h { color: #2563eb; font-weight: 600; }
.mx-c { display: inline-block; width: 18px; height: 18px; line-height: 18px; border-radius: 4px; font-weight: 600; font-size: 10.5px; }
.mx-ok { color: #15803d; background: #dcfce7; }
.mx-wa { color: #b45309; background: #fef3c7; }
.mx-rj { color: #b91c1c; background: #fee2e2; }
.mx-rs { color: #64748b; background: #f1f5f9; }
.mx-ot { color: #c2410c; background: #ffedd5; }
.mx-lv { color: #7e22ce; background: #f3e8ff; }
.mx-ex { color: #94a3b8; background: #f8fafc; }
.mx-legend { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 11.5px; color: var(--muted); }
.mx-legend span { display: inline-flex; align-items: center; gap: 4px; }

.drop-zone { border: 1.5px dashed var(--line-2); border-radius: 10px; padding: 22px; text-align: center;
  cursor: pointer; color: var(--muted); font-size: 13px; transition: border-color .15s, background .15s; }
.drop-zone:hover, .drop-zone.over { border-color: var(--brand); background: #f3f8ff; color: var(--brand); }
.ai-note { margin-top: 4px; padding: 4px 6px; border-radius: 5px; background: #f5f3ff; color: #5b21b6; font-size: 11px; }
.dd-time { display: inline-block; padding: 2px 9px; border-radius: 6px; background: #eef3fa; color: var(--brand); font-variant-numeric: tabular-nums; }
