:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #1e293b;
  --muted: #64748b;
  --primary: #1f6feb;
  --primary-dark: #1657bd;
  --primary-soft: #eaf1fe;
  --danger: #d64545;
  --danger-soft: #fdeeee;
  --ok: #17803d;
  --ok-soft: #e9f7ef;
  --warn: #b7791f;
  --warn-soft: #fdf5e6;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

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

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

a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ------------------------------ 通用组件 ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn:hover { background: #f8fafc; border-color: #b6c2d4; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); border-color: #eec4c4; background: var(--danger-soft); }
.btn-danger:hover { background: #fbe0e0; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }

input, select, textarea {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}
input[readonly] { background: #f6f8fa; color: var(--muted); }
textarea { height: auto; min-height: 62px; padding: 8px 10px; resize: vertical; }
label.field { display: block; }
label.field > span { display: block; margin-bottom: 5px; font-size: 12px; color: var(--muted); }
.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}
.checkbox input { width: 15px; height: 15px; margin: 0; }
.checkbox.checked { border-color: var(--primary); background: var(--primary-soft); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-body { padding: 16px; }

.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 12px;
  line-height: 18px;
  background: #f1f5f9;
  color: var(--muted);
  white-space: nowrap;
}
.tag-blue { background: var(--primary-soft); color: var(--primary); }
.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); }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }

.empty {
  padding: 48px 16px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

/* ------------------------------ 登录 / 注册 ------------------------------ */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 32px 16px;
  background: linear-gradient(160deg, #eff4fb 0%, #f7f9fc 55%, #eef6f2 100%);
}

.auth-wrap {
  width: 100%;
  max-width: 430px;
}

.auth-brand {
  text-align: center;
  margin-bottom: 22px;
}
.auth-brand h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 2px;
  font-weight: 600;
  color: #12233b;
}
.auth-brand p {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
}

.tabs {
  display: flex;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px;
  margin-bottom: 14px;
}
.tabs button {
  flex: 1;
  height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
}
.tabs button.active {
  background: var(--primary);
  color: #fff;
  font-weight: 500;
}

.auth-panel {
  padding: 22px 22px 18px;
}
.auth-panel .field { margin-bottom: 14px; }
.auth-panel .field > span { color: #475569; font-size: 13px; }
.auth-panel .field input { height: 40px; }
.auth-panel .btn-primary { width: 100%; height: 42px; font-size: 15px; margin-top: 4px; }

.auth-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.7;
  color: var(--muted);
  text-align: center;
}

.msg {
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.6;
  display: none;
}
.msg.show { display: block; }
.msg.error { background: var(--danger-soft); color: var(--danger); border: 1px solid #f3cfcf; }
.msg.ok { background: var(--ok-soft); color: var(--ok); border: 1px solid #cbe8d7; }

/* ------------------------------ 控制台布局 ------------------------------ */

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

.sidebar {
  width: 208px;
  flex: 0 0 208px;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand {
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--line);
}
.sidebar .brand strong { display: block; font-size: 15px; letter-spacing: 1px; }
.sidebar .brand small { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); letter-spacing: 0.5px; }
.nav { padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  border-radius: 6px;
  font-size: 13.5px;
  color: #334155;
  cursor: pointer;
  text-align: left;
}
.nav button:hover { background: #f5f8fd; }
.nav button.active { background: var(--primary-soft); color: var(--primary); font-weight: 500; }
.nav button .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.55; }
.sidebar .foot {
  margin-top: auto;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px;
  flex: 0 0 32px;
}
.user-chip .meta { min-width: 0; }
.user-chip .meta b { display: block; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip .meta span { font-size: 11px; color: var(--muted); }

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

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 600; }
.topbar .actions { margin-left: auto; display: flex; gap: 8px; }

.content { padding: 20px; flex: 1; }

/* ------------------------------ 概览 ------------------------------ */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat-card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.stat-card .label { font-size: 12px; color: var(--muted); letter-spacing: 0.3px; }
.stat-card .value { margin-top: 8px; font-size: 26px; font-weight: 650; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-card .value.small { font-size: 20px; }
.stat-card .sub { margin-top: 6px; font-size: 12px; color: var(--muted); }
.stat-card.accent { border-left: 3px solid var(--primary); }

.chart-bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.bar-row .name { width: 64px; color: var(--muted); flex: 0 0 64px; }
.bar-row .track { flex: 1; height: 12px; background: #eff3f8; border-radius: 6px; overflow: hidden; }
.bar-row .fill { height: 100%; background: linear-gradient(90deg, #4f8df7, #1f6feb); border-radius: 6px; }
.bar-row .val { width: 110px; text-align: right; color: var(--text); font-variant-numeric: tabular-nums; flex: 0 0 110px; }

/* ------------------------------ 筛选与表格 ------------------------------ */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  align-items: end;
}
.filters .field > span { font-size: 12px; }
.filter-actions { display: flex; gap: 8px; align-items: flex-end; }

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 300px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  font-size: 13px;
  white-space: nowrap;
}
table.grid thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  font-size: 12.5px;
}
table.grid tbody td {
  padding: 9px 12px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
table.grid tbody tr:hover { background: #fafcff; }
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.actions { position: sticky; right: 0; background: #fff; border-left: 1px solid #f1f5f9; }
table.grid tbody tr:hover td.actions { background: #fafcff; }

.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 4px 0;
  font-size: 13px;
  color: var(--muted);
}
.pager .spacer { flex: 1; }

/* ------------------------------ 弹窗 ------------------------------ */

.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 16px;
  z-index: 100;
  overflow: auto;
}
.modal {
  width: 100%;
  max-width: 860px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.25);
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .close {
  border: 0; background: transparent; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted);
}
.modal-body { padding: 18px 20px; max-height: 65vh; overflow: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line); background: #fbfcfe;
}

.form-section { margin-bottom: 18px; }
.form-section h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--primary);
  font-weight: 600;
  padding-left: 8px;
  border-left: 3px solid var(--primary);
  line-height: 16px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

/* ------------------------------ 审批 ------------------------------ */

.approval-list { display: flex; flex-direction: column; gap: 12px; }
.approval-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; background: #fff; }
.approval-item .head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.approval-item .head b { font-size: 14px; }
.approval-item .kv { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 16px; font-size: 12.5px; color: #475569; }
.approval-item .kv span b { color: var(--text); font-weight: 500; }
.approval-item .assign { margin-top: 14px; padding-top: 14px; border-top: 1px dashed var(--line); display: grid; gap: 10px; }
.approval-item .assign .checks { display: flex; flex-wrap: wrap; gap: 8px; }

/* ------------------------------ 字典 ------------------------------ */

.dict-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.dict-tabs button {
  height: 32px; padding: 0 14px; border-radius: 16px;
  border: 1px solid var(--line-strong); background: #fff; cursor: pointer; font-size: 13px; color: var(--muted);
}
.dict-tabs button.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 6px; background: #fff; font-size: 13px;
}
.chip .x { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0; }
.chip .x:hover { color: var(--danger); }

/* ------------------------------ 提示 ------------------------------ */

.toast-host {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}
.toast {
  padding: 9px 16px;
  border-radius: 6px;
  font-size: 13px;
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
}
.toast.error { background: var(--danger-soft); border-color: #f0caca; color: var(--danger); }
.toast.ok { background: var(--ok-soft); border-color: #cbe8d7; color: var(--ok); }
@keyframes toast-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

/* ------------------------------ 响应式 ------------------------------ */

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: 0; border-bottom: 1px solid var(--line);
  }
  .sidebar .brand { padding: 14px 16px; }
  .nav { flex-direction: row; overflow-x: auto; padding: 8px; }
  .nav button { white-space: nowrap; }
  .sidebar .foot { border-top: 1px solid var(--line); }
  .content { padding: 14px; }
  .table-wrap { max-height: none; }
}


/* ------------------------------ 目标进度 / 新增按钮 / 导入 ------------------------------ */

.table-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}
.table-toolbar .spacer { flex: 1; }

.btn-create {
  height: 40px;
  padding: 0 22px;
  font-size: 15px;
  font-weight: 600;
  background: var(--primary);
  color: #fff;
  border: 1px solid var(--primary);
  box-shadow: 0 6px 16px rgba(31, 111, 235, 0.28);
}
.btn-create:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 8px 20px rgba(31, 111, 235, 0.34);
}
.btn-outline { color: var(--primary); border-color: rgba(31, 111, 235, 0.45); background: var(--primary-soft); }
.btn-outline:hover { background: #dfeaff; }
a.btn { display: inline-flex; align-items: center; justify-content: center; }

.target-card { margin-bottom: 18px; }
.target-nums { display: flex; gap: 36px; flex-wrap: wrap; margin-bottom: 14px; }
.target-label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.target-value { font-size: 22px; font-weight: 600; }
.target-goal { font-size: 16px; font-weight: 600; color: var(--muted); }
.target-value.over { color: var(--ok); }
.progress { height: 14px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6, #1f6feb);
  border-radius: 999px;
  transition: width 0.3s ease;
}
.progress.over .progress-fill { background: linear-gradient(90deg, #22a06b, #17803d); }
.target-sub { margin-top: 8px; font-size: 12px; }

.import-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.import-summary { display: flex; gap: 8px; margin-top: 12px; }
.import-errors {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: var(--danger);
  max-height: 220px;
  overflow: auto;
  line-height: 1.8;
}
.rank-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 18px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: flex; align-items: center; gap: 10px; }
.rank-no {
  width: 22px; height: 22px; flex: 0 0 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; color: var(--muted); background: #f1f5f9; border-radius: 6px;
}
.rank-no.top { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.rank-name { flex: 0 0 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.rank-bar { flex: 1; height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.rank-fill { height: 100%; background: linear-gradient(90deg, #93c5fd, #1f6feb); border-radius: 999px; }
.rank-amount { flex: 0 0 96px; text-align: right; font-size: 12px; color: var(--text); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) { .rank-grid { grid-template-columns: 1fr; } }