:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e5e8ee;
  --border-strong: #d3d9e3;
  --text: #1b1f26;
  --text-soft: #5b6472;
  --muted: #8a93a3;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #eef4ff;
  --success: #16a34a;
  --success-soft: #eafaf0;
  --warn: #d97706;
  --warn-soft: #fff5e6;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --purple: #7c3aed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 4px 16px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 48px rgba(16, 24, 40, .16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- 登录 ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(1000px 500px at 85% -10%, #e0ecff 0%, transparent 60%),
    radial-gradient(800px 400px at 5% 110%, #eaf6ef 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 32px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-logo {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 15px;
}
.auth-title { font-size: 20px; font-weight: 650; letter-spacing: -.2px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 22px; }
.auth-tabs { display: flex; gap: 4px; background: #f1f3f7; padding: 4px; border-radius: 9px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; border: 0; background: transparent; padding: 7px 0; border-radius: 7px;
  cursor: pointer; color: var(--text-soft); font-weight: 500;
}
.auth-tabs button.active { background: #fff; color: var(--text); box-shadow: 0 1px 3px rgba(16,24,40,.1); }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 212px; flex: 0 0 212px; background: #fff; border-right: 1px solid var(--border);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 16px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 8px; flex: 0 0 32px;
  background: linear-gradient(135deg, #2563eb, #4f46e5); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.2px; }
.brand-sub { font-size: 11.5px; color: var(--muted); margin-top: -2px; }

.nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
.nav-group { font-size: 11px; color: var(--muted); padding: 12px 10px 6px; letter-spacing: .4px; }
.nav a {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 8px;
  color: var(--text-soft); font-weight: 500; margin-bottom: 2px; cursor: pointer;
}
.nav a:hover { background: #f4f6f9; color: var(--text); }
.nav a.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.nav a .ico { width: 17px; text-align: center; opacity: .85; font-size: 15px; }
.nav .badge {
  margin-left: auto; background: var(--danger); color: #fff; font-size: 11px;
  padding: 0 6px; border-radius: 9px; font-weight: 600; line-height: 17px;
}

.sidebar-foot { border-top: 1px solid var(--border); padding: 12px; }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 6px 6px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-dark);
  display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: 0 0 30px;
}
.user-name { font-weight: 600; font-size: 13px; line-height: 1.3; }
.user-role { font-size: 11px; color: var(--muted); }
.link-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 12px; padding: 2px 4px; }
.link-btn:hover { color: var(--danger); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 14px 24px;
  display: flex; align-items: center; gap: 14px; position: sticky; top: 0; z-index: 20;
}
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; letter-spacing: -.2px; }
.topbar .desc { color: var(--muted); font-size: 12.5px; }
.topbar-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.content { padding: 20px 24px 60px; flex: 1; }

/* ---------- 通用组件 ---------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card-head {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.card-head h2 { font-size: 14.5px; margin: 0; font-weight: 650; }
.card-head .sub { color: var(--muted); font-size: 12.5px; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }

.btn {
  border: 1px solid var(--border-strong); background: #fff; color: var(--text);
  padding: 6px 13px; border-radius: 8px; cursor: pointer; font-weight: 500;
  transition: all .12s; white-space: nowrap;
}
.btn:hover { background: #f7f9fc; border-color: #bcc6d6; }
.btn:disabled { opacity: .5; 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: #f0c2c2; background: #fff; }
.btn-danger:hover { background: var(--danger-soft); border-color: #e8a5a5; }
.btn-sm { padding: 3px 9px; font-size: 12.5px; border-radius: 6px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: #f1f3f7; }

.input, .select, .textarea {
  width: 100%; border: 1px solid var(--border-strong); border-radius: 8px;
  padding: 7px 11px; background: #fff; outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.textarea { min-height: 78px; resize: vertical; }
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.label { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-soft); margin-bottom: 5px; }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left; font-size: 12px; font-weight: 600; color: var(--text-soft);
  padding: 9px 12px; border-bottom: 1px solid var(--border); background: #fafbfd; white-space: nowrap;
}
td { padding: 10px 12px; border-bottom: 1px solid #f0f2f6; vertical-align: middle; }
tbody tr:hover { background: #fafbfd; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

.tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 20px;
  font-size: 12px; font-weight: 500; line-height: 20px; white-space: nowrap; border: 1px solid transparent;
}
.tag .dot { width: 6px; height: 6px; border-radius: 50%; }
.tag-pick {
  cursor: pointer; user-select: none; padding: 3px 11px; border-radius: 20px;
  border: 1px solid var(--border-strong); background: #fff; font-size: 12.5px;
}
.tag-pick.on { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }
.tags-wrap { display: flex; flex-wrap: wrap; gap: 5px; }

.pill {
  display: inline-block; padding: 1px 8px; border-radius: 6px; font-size: 12px;
  font-weight: 600; line-height: 19px;
}
.pill-green { background: var(--success-soft); color: var(--success); }
.pill-blue  { background: var(--primary-soft); color: var(--primary-dark); }
.pill-amber { background: var(--warn-soft); color: var(--warn); }
.pill-red   { background: var(--danger-soft); color: var(--danger); }
.pill-gray  { background: #f1f3f7; color: var(--text-soft); }
.pill-purple{ background: #f3edff; color: var(--purple); }

.level { font-weight: 700; font-size: 12.5px; }
.level-A { color: var(--danger); }
.level-B { color: var(--warn); }
.level-C { color: var(--muted); }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .ico { font-size: 34px; opacity: .5; display: block; margin-bottom: 8px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.stat {
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12.5px; color: var(--text-soft); }
.stat .v { font-size: 25px; font-weight: 680; letter-spacing: -.6px; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat .d { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.accent .v { color: var(--primary); }
.stat.green .v { color: var(--success); }
.stat.amber .v { color: var(--warn); }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 130px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; height: 100%; justify-content: flex-end; }
.bar-stack { width: 100%; display: flex; gap: 3px; align-items: flex-end; height: 100%; }
.bar { flex: 1; border-radius: 4px 4px 0 0; min-height: 3px; background: var(--primary); }
.bar.alt { background: #c7d7f7; }
.bar-col .lbl { font-size: 11px; color: var(--muted); }
.legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-soft); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; }

.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.toolbar .grow { flex: 1; min-width: 160px; }
.filter-row { padding: 11px 16px; border-bottom: 1px solid var(--border); background: #fafbfd; display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-start; }
.filter-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.filter-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.mini-select { border: 1px solid var(--border-strong); border-radius: 7px; padding: 4px 8px; font-size: 12.5px; background: #fff; }

.bulkbar {
  display: none; align-items: center; gap: 10px; padding: 9px 16px;
  background: var(--primary-soft); border-bottom: 1px solid #d6e4ff; font-size: 13px;
}
.bulkbar.show { display: flex; }
.bulkbar .count { font-weight: 650; color: var(--primary-dark); }
.bulkbar .right { margin-left: auto; display: flex; gap: 8px; }

.pager { display: flex; align-items: center; gap: 10px; padding: 12px 16px; font-size: 13px; color: var(--text-soft); }
.pager .right { margin-left: auto; display: flex; gap: 6px; align-items: center; }

/* ---------- 抽屉 ---------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .32); z-index: 60;
  display: flex; justify-content: flex-end; animation: fade .15s ease;
}
.drawer {
  width: min(560px, 94vw); background: #fff; height: 100%; overflow-y: auto;
  box-shadow: var(--shadow-lg); animation: slide .2s cubic-bezier(.2,.8,.3,1);
  display: flex; flex-direction: column;
}
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slide { from { transform: translateX(28px); opacity: .6 } to { transform: none; opacity: 1 } }
.drawer-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: #fff; z-index: 2;
  display: flex; align-items: flex-start; gap: 12px;
}
.drawer-head h3 { margin: 0; font-size: 16.5px; font-weight: 650; }
.drawer-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
.drawer-close { margin-left: auto; border: 0; background: #f1f3f7; width: 28px; height: 28px; border-radius: 7px; cursor: pointer; color: var(--text-soft); }
.drawer-body { padding: 18px 20px 40px; flex: 1; }
.drawer-foot {
  position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--border);
  padding: 12px 20px; display: flex; gap: 8px;
}

.kv { display: grid; grid-template-columns: 82px 1fr; gap: 8px 12px; font-size: 13.5px; }
.kv .k { color: var(--muted); }

.section { margin-bottom: 22px; }
.section-title { font-size: 13px; font-weight: 650; color: var(--text-soft); margin-bottom: 9px; display: flex; align-items: center; gap: 8px; }
.section-title .right { margin-left: auto; font-weight: 400; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px; width: 2px; background: #e9edf3; }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item::before {
  content: ''; position: absolute; left: -19px; top: 6px; width: 10px; height: 10px;
  border-radius: 50%; background: #fff; border: 2px solid var(--primary);
}
.tl-meta { font-size: 12px; color: var(--muted); margin-bottom: 3px; }
.tl-body { background: #f7f9fc; border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; font-size: 13.5px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(16, 24, 40, .38); z-index: 80;
  display: grid; place-items: center; padding: 20px; animation: fade .15s ease;
}
.modal {
  width: min(520px, 96vw); max-height: 88vh; overflow-y: auto; background: #fff;
  border-radius: 14px; box-shadow: var(--shadow-lg); animation: pop .16s cubic-bezier(.2,.8,.3,1);
}
@keyframes pop { from { transform: scale(.97); opacity: 0 } to { transform: none; opacity: 1 } }
.modal-head { padding: 17px 20px 13px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 650; }
.modal-head .sub { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end;
  position: sticky; bottom: 0; background: #fff; border-radius: 0 0 14px 14px;
}

/* ---------- Toast ---------- */
#toast-root { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: #1b1f26; color: #fff; padding: 9px 18px; border-radius: 9px; font-size: 13.5px;
  box-shadow: var(--shadow-lg); animation: toastIn .18s ease;
}
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }
@keyframes toastIn { from { transform: translateY(-10px); opacity: 0 } to { transform: none; opacity: 1 } }

/* ---------- 杂项 ---------- */
.muted { color: var(--muted); }
.soft { color: var(--text-soft); }
.small { font-size: 12.5px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.clickable { cursor: pointer; }
.clickable:hover { color: var(--primary); text-decoration: underline; }
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.progress { height: 7px; background: #eef1f6; border-radius: 5px; overflow: hidden; min-width: 78px; }
.progress i { display: block; height: 100%; background: var(--primary); border-radius: 5px; }
.center { text-align: center; }
.right { text-align: right; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.flex-line { display: flex; align-items: center; gap: 8px; }
.spacer { flex: 1; }
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; }
.switch input { width: 36px; height: 20px; appearance: none; background: #d5dae3; border-radius: 20px; position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked { background: var(--primary); }
.switch input:checked::after { transform: translateX(16px); }
