:root {
  --bg: #f5f6fa;
  --panel: #ffffff;
  --line: #e8eaf1;
  --text: #1c2033;
  --sub: #7a8199;
  --primary: #4f46e5;
  --primary-soft: #eef0ff;
  --green: #0f9d76;
  --red: #e05260;
  --amber: #d98a11;
  --radius: 14px;
  --shadow: 0 2px 10px rgba(28, 32, 51, .05);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; font-size: 14px; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 10%, #e9ecff 0, transparent 45%),
              radial-gradient(circle at 85% 90%, #e6f7f1 0, transparent 40%), #f5f6fa;
  z-index: 50;
}
.login-card {
  width: 380px; background: #fff; border-radius: 20px; padding: 34px 32px 28px;
  box-shadow: 0 20px 60px rgba(40, 48, 90, .12);
}
.login-card h1 { font-size: 22px; margin: 0 0 6px; }
.login-card p { color: var(--sub); margin: 0 0 22px; font-size: 13px; }
.login-card input {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  outline: none; margin-bottom: 14px; background: #fafbff;
}
.login-card input:focus { border-color: var(--primary); background: #fff; }
.login-card button {
  width: 100%; padding: 12px; border: 0; border-radius: 10px; background: var(--primary);
  color: #fff; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #4338ca; }
.login-err { color: var(--red); font-size: 12px; height: 16px; margin-bottom: 8px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 224px; flex-shrink: 0; background: #141728; color: #cfd3e6;
  display: flex; flex-direction: column; padding: 22px 14px; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 22px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center;
  background: linear-gradient(135deg, #6366f1, #22c1a4); color: #fff; font-weight: 700; font-size: 16px;
}
.brand-name { font-size: 15px; font-weight: 600; color: #fff; }
.brand-sub { font-size: 11px; color: #7c829c; margin-top: 2px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 10px;
  color: #b6bbd2; cursor: pointer; user-select: none; font-size: 14px;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active { background: rgba(99,102,241,.22); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .9; }
.sidebar-foot { margin-top: auto; font-size: 11px; color: #6a7089; padding: 12px 8px 0; line-height: 1.6; }

.main { flex: 1; min-width: 0; padding: 22px 26px 40px; }
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.topbar h2 { margin: 0; font-size: 20px; }
.topbar .sub { color: var(--sub); font-size: 12px; margin-top: 4px; }
.top-actions { display: flex; align-items: center; gap: 10px; }

/* ---------- 通用组件 ---------- */
.card {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--line); padding: 18px 20px;
}
.card h3 { margin: 0 0 14px; font-size: 15px; }
.grid { display: grid; gap: 16px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }

.kpi-label { color: var(--sub); font-size: 12px; margin-bottom: 8px; }
.kpi-value { font-size: 24px; font-weight: 700; letter-spacing: -.3px; }
.kpi-foot { margin-top: 6px; font-size: 12px; color: var(--sub); }
.kpi-value.green { color: var(--green); }
.kpi-value.red { color: var(--red); }

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--text); cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: #cdd2e4; background: #fafbff; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: #4338ca; }
.btn.danger { color: var(--red); border-color: #f3cdd2; }
.btn.ghost { background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--sub); }
input[type=text], input[type=password], input[type=date], input[type=number], select, textarea {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #fafbff; color: var(--text);
  min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); background: #fff; }
textarea { resize: vertical; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.hint { font-size: 12px; color: var(--sub); line-height: 1.6; }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 10px; border-bottom: 1px solid var(--line); font-size: 13px; white-space: nowrap; }
th { color: var(--sub); font-weight: 500; font-size: 12px; background: #fbfcff; }
tbody tr:hover { background: #fafbff; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow: auto; border-radius: 10px; }
.empty { padding: 34px 0; text-align: center; color: var(--sub); font-size: 13px; }

.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; background: #eef0ff; color: #4f46e5; }
.tag.green { background: #e7f7f1; color: #0f9d76; }
.tag.gray { background: #f0f1f6; color: #7a8199; }
.tag.red { background: #fdeef0; color: #e05260; }
.tag.amber { background: #fdf3e3; color: #c07a08; }

.copy-box {
  display: flex; gap: 8px; align-items: center; background: #f7f8fd; border: 1px dashed #c9cee4;
  border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, Consolas, monospace; font-size: 12px;
  word-break: break-all; line-height: 1.6;
}
.copy-box span { flex: 1; }

.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #1c2033; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 13px;
  opacity: 0; transition: .25s; pointer-events: none; z-index: 99; box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: #c23b4a; }

dialog {
  border: 0; border-radius: 16px; padding: 0; width: 520px; max-width: 92vw;
  box-shadow: 0 24px 60px rgba(20, 23, 40, .25);
}
dialog::backdrop { background: rgba(20, 23, 40, .35); }
.dialog-head { padding: 18px 20px 0; font-weight: 600; font-size: 15px; }
.dialog-body { padding: 16px 20px; display: grid; gap: 12px; }
.dialog-body .grid-2 { gap: 12px; }
.dialog-foot { padding: 0 20px 18px; display: flex; justify-content: flex-end; gap: 10px; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; margin-top: 12px; font-size: 12px; color: var(--sub); }

.chart { width: 100%; height: 220px; }
.chart svg { width: 100%; height: 100%; overflow: visible; }
.legend { display: flex; gap: 16px; font-size: 12px; color: var(--sub); margin-top: 6px; }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }

.section { display: none; }
.section.active { display: block; }
.mt16 { margin-top: 16px; }
.mb12 { margin-bottom: 12px; }
.w100 { width: 100%; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.nowrap { white-space: nowrap; }
.ellipsis { max-width: 240px; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { display: none; }
  .main { padding: 16px; }
  .grid-4 { grid-template-columns: 1fr; }
}
