:root {
  --bg: #f4f6fa;
  --panel: #ffffff;
  --ink: #0f1b2d;
  --ink-2: #4a5b70;
  --ink-3: #8a99ab;
  --line: #e4eaf2;
  --line-2: #eef2f7;
  --brand: #2f6fed;
  --brand-d: #2559c9;
  --brand-soft: #ebf2ff;
  --ok: #0f9f6e;
  --ok-soft: #e8f7f1;
  --warn: #d98510;
  --warn-soft: #fdf4e3;
  --danger: #d93a3f;
  --danger-soft: #fdeceb;
  --shadow: 0 1px 2px rgba(15, 27, 45, 0.04), 0 8px 24px rgba(15, 27, 45, 0.06);
  --radius: 10px;
  --sidebar: 224px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", "Hiragino Sans GB", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); text-decoration: none; }

/* ---------------------------------------------------------------- 登录页 */

.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: #fff;
}

.login-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(150deg, #17356b 0%, #2456b6 52%, #2f6fed 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-hero::after {
  content: "";
  position: absolute;
  right: -160px;
  bottom: -180px;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.22), rgba(255,255,255,0) 62%);
}

.login-hero .brand-lg { display: flex; align-items: center; gap: 12px; font-size: 15px; letter-spacing: .12em; opacity: .92; }
.login-hero h1 { font-size: 34px; line-height: 1.35; margin: 0 0 18px; font-weight: 700; letter-spacing: .5px; }
.login-hero p { font-size: 13.5px; line-height: 2; color: rgba(255,255,255,.8); margin: 0; max-width: 430px; }
.hero-points { list-style: none; padding: 0; margin: 32px 0 0; display: grid; gap: 14px; }
.hero-points li { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: rgba(255,255,255,.9); }
.hero-points svg { flex: 0 0 auto; margin-top: 2px; }
.hero-foot { font-size: 12px; color: rgba(255,255,255,.55); letter-spacing: .04em; }

.login-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.login-card { width: 100%; max-width: 348px; }
.login-card h2 { font-size: 20px; margin: 0 0 6px; letter-spacing: .02em; }
.login-card .sub { color: var(--ink-3); font-size: 12.5px; margin-bottom: 28px; }

.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 7px; letter-spacing: .02em; }

.input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.input:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(47,111,237,.12); }
.input::placeholder { color: #b6c0cd; }

.btn {
  height: 36px;
  padding: 0 16px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .14s;
  white-space: nowrap;
}
.btn:hover { border-color: #cdd8e6; background: #f7f9fc; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-d); border-color: var(--brand-d); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--line-2); }
.btn-danger { color: var(--danger); border-color: #f3cdcb; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.btn-block { width: 100%; height: 42px; font-size: 14px; }

.login-err { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-bottom: 4px; }

.demo-box {
  margin-top: 26px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 12px;
  color: var(--ink-3);
  line-height: 1.9;
  background: #fafcfe;
}
.demo-box b { color: var(--ink-2); font-weight: 600; }

/* ---------------------------------------------------------------- 主框架 */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: #0f1e33;
  color: #cdd7e5;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-logo {
  height: 66px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex: 0 0 auto;
}
.side-logo .mark {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(140deg, #3d7bf5, #2f6fed);
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700; color: #fff; letter-spacing: -.5px;
}
.side-logo .txt { font-size: 13.5px; color: #fff; font-weight: 600; letter-spacing: .04em; line-height: 1.3; }
.side-logo .txt small { display: block; font-size: 10px; color: #7d8ea6; font-weight: 400; letter-spacing: .16em; margin-top: 2px; }

.side-nav { padding: 14px 10px; flex: 1 1 auto; overflow: auto; }
.side-group { font-size: 10.5px; color: #62748c; letter-spacing: .14em; padding: 12px 10px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; margin-bottom: 2px;
  color: #c2cede; font-size: 13px; cursor: pointer; user-select: none;
  transition: background .14s, color .14s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 14px rgba(47,111,237,.35); }
.nav-item svg { opacity: .9; }

.side-foot { padding: 12px; border-top: 1px solid rgba(255,255,255,.07); flex: 0 0 auto; }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.user-chip .ava {
  width: 30px; height: 30px; border-radius: 50%; flex: 0 0 auto;
  background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center;
  font-size: 12px; font-weight: 600;
}
.user-chip .meta { min-width: 0; flex: 1; }
.user-chip .meta b { display: block; font-size: 12.5px; color: #eaf0f8; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .meta span { font-size: 10.5px; color: #7d8ea6; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 0; background: transparent;
  color: #8fa2ba; display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 62px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.page-title { font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.page-title small { font-weight: 400; color: var(--ink-3); font-size: 12px; margin-left: 10px; }
.topbar .spacer { flex: 1; }

.period-pick {
  display: flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 10px 0 12px;
  border: 1px solid var(--line); border-radius: 8px; background: #fbfcfe;
}
.period-pick select { border: 0; background: transparent; outline: none; font-size: 13px; color: var(--ink); cursor: pointer; padding-right: 2px; }

.content { padding: 20px 24px 40px; flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- 组件 */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; border-bottom: 1px solid var(--line-2);
}
.card-head h3 { font-size: 13.5px; margin: 0; font-weight: 600; letter-spacing: .01em; }
.card-head .spacer { flex: 1; }
.card-body { padding: 16px 18px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px; position: relative; overflow: hidden;
}
.stat .k { font-size: 11.5px; color: var(--ink-3); letter-spacing: .04em; }
.stat .v { font-size: 24px; font-weight: 700; margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 12px; font-weight: 400; color: var(--ink-3); margin-left: 3px; }
.stat::after { content: ""; position: absolute; right: -20px; top: -20px; width: 60px; height: 60px; border-radius: 50%; background: var(--brand-soft); opacity: .6; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  height: 22px; padding: 0 9px; border-radius: 11px;
  font-size: 11.5px; font-weight: 500; letter-spacing: .02em;
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }
.pill-muted { background: #f1f4f9; color: var(--ink-3); }
.pill-brand { background: var(--brand-soft); color: var(--brand); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 工具条 */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.divider-v { width: 1px; height: 20px; background: var(--line); margin: 0 4px; }

/* 部门标签 */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab {
  height: 32px; padding: 0 14px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--ink-2); font-size: 12.5px; display: inline-flex; align-items: center; gap: 7px;
}
.tab:hover { background: #fff; border-color: var(--line); }
.tab.active { background: #fff; border-color: var(--line); color: var(--brand); font-weight: 600; box-shadow: var(--shadow); }
.tab .cnt { font-size: 11px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.tab.active .cnt { color: var(--brand); }

/* 表格 */
.table-wrap {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: auto; box-shadow: var(--shadow);
  max-height: calc(100vh - 300px);
}
table.grid { border-collapse: separate; border-spacing: 0; width: max-content; min-width: 100%; }
table.grid th, table.grid td {
  border-right: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line-2);
  padding: 0; height: 36px;
  font-size: 12px;
}
table.grid thead th {
  position: sticky; top: 0; z-index: 3;
  background: #f7f9fc;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 11.5px;
  text-align: center;
  white-space: pre-line;
  line-height: 1.35;
  padding: 8px 6px;
  height: auto;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
}
table.grid tbody td { background: #fff; text-align: center; }
table.grid tbody tr:hover td { background: #fafcff; }
table.grid tbody tr.dirty td { background: #fffdf3; }
table.grid tbody tr.missing td { background: #fffafa; }
table.grid tbody tr:hover td.sticky { background: #f4f8ff; }

td.sticky, th.sticky { position: sticky; z-index: 2; }
th.sticky { z-index: 4; }
td.sticky { background: #fff; }
.col-seq { left: 0; width: 44px; min-width: 44px; }
.col-no { left: 44px; width: 92px; min-width: 92px; }
.col-name { left: 136px; width: 84px; min-width: 84px; box-shadow: 2px 0 6px -3px rgba(15,27,45,.14); }
thead .col-seq, thead .col-no, thead .col-name { z-index: 5; }

.cell-text { position: relative; padding: 0 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--ink-2); }
.cell-ro { color: var(--ink-3); background: #fbfcfe !important; }

input.cell {
  width: 100%; height: 35px; border: 0; background: transparent;
  text-align: center; outline: none; border-radius: 0;
  font-variant-numeric: tabular-nums;
  transition: box-shadow .12s, background .12s;
}
input.cell:focus { background: #fff; box-shadow: inset 0 0 0 2px var(--brand); position: relative; z-index: 1; }
input.cell::placeholder { color: #cdd6e2; }
input.cell:disabled { color: var(--ink-2); background: transparent; cursor: default; }
input.cell.warn { background: #fff7e6; }

tfoot td {
  position: sticky; bottom: 0; background: #f7f9fc !important;
  font-weight: 600; color: var(--ink); font-size: 12px; text-align: center;
  border-top: 1px solid var(--line);
}
tfoot .lbl { text-align: right; padding-right: 12px; color: var(--ink-2); }

/* 进度条 */
.bar { height: 6px; border-radius: 3px; background: #edf1f7; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); transition: width .4s; }
.bar.ok > i { background: var(--ok); }
.bar.warn > i { background: var(--warn); }

/* 部门卡片 */
.dept-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 14px; }
.dept-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.dept-card:hover { border-color: #cfdcf2; transform: translateY(-1px); }
.dept-card .top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.dept-card .nm { font-size: 13.5px; font-weight: 600; }
.dept-card .nums { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-3); margin-bottom: 6px; }
.dept-card .nums b { color: var(--ink); font-variant-numeric: tabular-nums; }
.dept-card .foot { margin-top: 14px; display: flex; gap: 6px; }

/* 表单 */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.hint { font-size: 11.5px; color: var(--ink-3); line-height: 1.7; }

select.input, textarea.input { height: 36px; }
textarea.input { height: auto; padding: 9px 12px; resize: vertical; }

/* 通用数据表 */
table.simple { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.simple th {
  text-align: left; font-weight: 600; color: var(--ink-2); font-size: 11.5px;
  padding: 10px 12px; background: #f7f9fc; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.simple td { padding: 10px 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.simple tbody tr:hover td { background: #fafcff; }
table.simple td.right { text-align: right; }
table.simple td.num { text-align: right; font-variant-numeric: tabular-nums; }

.tag { display: inline-block; padding: 1px 7px; border-radius: 5px; font-size: 11px; background: #f1f4f9; color: var(--ink-2); }
.tag-blue { background: var(--brand-soft); color: var(--brand); }
.tag-green { background: var(--ok-soft); color: var(--ok); }
.tag-amber { background: var(--warn-soft); color: var(--warn); }
.tag-red { background: var(--danger-soft); color: var(--danger); }

input.mini {
  height: 30px; padding: 0 8px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; width: 100%; outline: none; font-variant-numeric: tabular-nums;
}
input.mini:hover { border-color: var(--line); background: #fff; }
input.mini:focus { border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(47,111,237,.1); }

/* 空状态 */
.empty { padding: 56px 20px; text-align: center; color: var(--ink-3); }
.empty h4 { margin: 14px 0 6px; font-size: 14px; color: var(--ink-2); font-weight: 600; }
.empty p { margin: 0; font-size: 12.5px; line-height: 1.8; }

/* 锁定提示条 */
.banner {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px; border-radius: var(--radius);
  font-size: 12.5px; margin-bottom: 14px; border: 1px solid transparent;
}
.banner-lock { background: var(--danger-soft); color: #9c2a2e; border-color: #f6d3d1; }
.banner-warn { background: var(--warn-soft); color: #8a5a08; border-color: #f6e3c2; }
.banner-ok { background: var(--ok-soft); color: #0a6d4d; border-color: #cceedd; }
.banner-info { background: var(--brand-soft); color: var(--brand-d); border-color: #d8e5ff; }
.banner .spacer { flex: 1; }

/* toast */
#toasts { position: fixed; top: 20px; right: 22px; z-index: 999; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast {
  min-width: 240px; max-width: 400px; background: #fff; border: 1px solid var(--line);
  border-left: 3px solid var(--brand); border-radius: 8px; box-shadow: 0 10px 34px rgba(15,27,45,.14);
  padding: 11px 14px; font-size: 12.5px; animation: slidein .22s ease;
  pointer-events: auto;
}
.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: 12.5px; margin-bottom: 3px; }
.toast span { color: var(--ink-2); line-height: 1.6; word-break: break-all; }
@keyframes slidein { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(15, 27, 45, .42); z-index: 200;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  animation: fade .15s;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 12px; width: 100%; max-width: 520px;
  box-shadow: 0 24px 70px rgba(15,27,45,.28); overflow: hidden;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }
.modal.wide { max-width: 720px; }
.modal-head { padding: 16px 20px; border-bottom: 1px solid var(--line-2); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.modal-head .spacer { flex: 1; }
.modal-body { padding: 18px 20px; max-height: 66vh; overflow: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--line-2); display: flex; gap: 8px; justify-content: flex-end; background: #fbfcfe; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.check-item {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; cursor: pointer;
  background: #fbfcfe;
}
.check-item:hover { border-color: #cdd8e6; }
.check-item input { accent-color: var(--brand); }
.check-item.on { border-color: var(--brand); background: var(--brand-soft); color: var(--brand-d); }

.row-gap { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt20 { margin-top: 20px; }
.mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 11.5px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.spacer { flex: 1; }
.hidden { display: none !important; }

.loading { padding: 60px; text-align: center; color: var(--ink-3); font-size: 12.5px; }

@media (max-width: 900px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .sidebar { width: 68px; flex: 0 0 68px; }
  .side-logo .txt, .nav-item span, .user-chip .meta, .side-group { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 14px; }
}

/* ===== 校验与授权（2026-11 新增） ===== */
.banner-danger { background: var(--danger-soft); color: #a32328; border-color: #f5c7c5; font-weight: 500; }
.banner-danger b { color: var(--danger); }

table.grid tbody tr.invalid td { background: #fff5f4 !important; }
table.grid tbody tr.invalid td.col-seq { box-shadow: inset 3px 0 0 var(--danger); }
table.grid tbody tr.explained td { background: #fffcf2 !important; }
table.grid tbody tr.explained td.col-seq { box-shadow: inset 3px 0 0 var(--warn); }

.bad-dot { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); box-shadow: 0 0 0 2px #fff; }
.bad-dot.ok { background: var(--warn); }

td.note-cell { padding: 2px 4px !important; }
td.note-cell input.cell { height: 24px; }
input.cell.need-note { background: #fff2f1; box-shadow: inset 0 0 0 1px #f0b3b0; }
.diff-tip { display: block; font-size: 10.5px; line-height: 1.3; padding: 0 2px 1px; text-align: left; white-space: nowrap; }
.diff-tip.bad { color: var(--danger); }
.diff-tip.ok { color: var(--warn); }

td.col-admin input.cell { background: #f7f8fa; color: var(--ink-2); }
td.col-admin input.cell:focus { background: #fff; }

.dept-group { margin-bottom: 10px; }
.dept-group-h { font-size: 11.5px; color: var(--ink-3); margin: 0 0 6px 2px; padding-left: 6px; border-left: 3px solid var(--brand-soft); }
.stat-bad { background: var(--danger-soft); }
.stat-bad .v { color: var(--danger); }

textarea.input { resize: vertical; min-height: 64px; padding: 8px 10px; line-height: 1.5; font: inherit; }

/* ---- 导入模式选择弹窗 ---- */
.mode-opt {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--line, #e3e8ef);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.mode-opt:hover { border-color: var(--brand, #3b6ef5); background: #f7f9ff; }
.mode-opt:has(input:checked) { border-color: var(--brand, #3b6ef5); background: #f5f8ff; }
.mode-opt input { margin-top: 3px; accent-color: var(--brand, #3b6ef5); }
