:root {
  --primary: #4f46e5;
  --primary-light: #eef2ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --ink: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --bg: #f4f6fb;
  --card: #ffffff;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14px; line-height: 1.5;
}
.hidden { display: none !important; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

/* ---------- 登录 ---------- */
.login-page { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.login-bg { position: absolute; inset: 0; background: linear-gradient(135deg, #1e1b4b 0%, #3730a3 45%, #4f46e5 100%); }
.login-bg::after {
  content: ""; position: absolute; width: 700px; height: 700px; right: -180px; top: -220px;
  background: radial-gradient(circle, rgba(255,255,255,.12), transparent 65%); border-radius: 50%;
}
.login-card {
  position: relative; z-index: 1; width: 380px; background: #fff; padding: 40px 38px 34px;
  border-radius: 20px; box-shadow: 0 24px 70px rgba(0,0,0,.28); text-align: center;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 16px;
  background: linear-gradient(135deg, #4f46e5, #7c3aed); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 700; letter-spacing: 1px;
}
.login-card h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--muted); margin-bottom: 26px; font-size: 13px; }
.field-label { display: block; text-align: left; color: var(--muted); font-size: 12px; margin: 14px 0 6px; }
.input, .select, .textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); outline: none; transition: border-color .2s, box-shadow .2s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
.textarea { resize: vertical; min-height: 76px; }
.btn {
  border: 0; border-radius: 9px; padding: 9px 16px; cursor: pointer; font-weight: 600;
  transition: transform .12s, box-shadow .2s, background .2s; white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(79,70,229,.25); }
.btn-primary:hover { background: #4338ca; }
.btn-ghost { background: var(--primary-light); color: var(--primary); }
.btn-light { background: #f1f5f9; color: var(--ink); }
.btn-danger { background: #fee2e2; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; margin-top: 24px; padding: 12px; font-size: 15px; }
.login-error { color: var(--danger); min-height: 20px; margin-top: 12px; font-size: 13px; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex-shrink: 0; background: linear-gradient(180deg, #1f2440 0%, #151a30 100%);
  color: #cbd5e1; display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 10;
}
.brand {
  display: flex; align-items: center; gap: 11px; padding: 22px 20px; color: #fff;
  font-size: 15px; font-weight: 700; border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-mark {
  width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #6366f1, #8b5cf6); font-size: 12px; letter-spacing: .5px;
}
.nav { padding: 14px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px; margin-bottom: 3px;
  color: #a5b4c8; text-decoration: none; border-radius: 9px; font-size: 13.5px; transition: background .18s, color .18s;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, #4f46e5, #6366f1); color: #fff; box-shadow: 0 4px 14px rgba(79,70,229,.35); }
.nav-icon { width: 18px; text-align: center; font-size: 15px; opacity: .9; }
.sidebar-footer { padding: 16px 20px; color: #64748b; font-size: 11px; border-top: 1px solid rgba(255,255,255,.06); }
.main { margin-left: 232px; flex: 1; min-width: 0; }
.topbar {
  height: 64px; background: #fff; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; justify-content: space-between; padding: 0 28px; position: sticky; top: 0; z-index: 5;
}
.topbar-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
.user-chip {
  display: flex; align-items: center; gap: 10px; margin-left: 12px; padding-left: 14px;
  border-left: 1px solid var(--line); color: var(--ink); font-size: 13px;
}
.link-btn { background: none; border: 0; color: var(--primary); cursor: pointer; font-size: 12px; }
.content { padding: 24px 28px 40px; }

/* ---------- 卡片 / 表格 ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 700; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.card-title::before { content: ""; width: 3px; height: 15px; background: var(--primary); border-radius: 2px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .input, .toolbar .select { width: auto; min-width: 140px; }
.toolbar .spacer { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { text-align: left; color: var(--muted); font-weight: 600; padding: 10px 12px; background: #f8fafc; white-space: nowrap; }
td { padding: 11px 12px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: #fafbff; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge.green { background: #dcfce7; color: #15803d; }
.badge.red { background: #fee2e2; color: #b91c1c; }
.badge.amber { background: #fef3c7; color: #b45309; }
.badge.gray { background: #f1f5f9; color: #475569; }
.badge.blue { background: #dbeafe; color: #1d4ed8; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.muted { color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 16px; color: var(--muted); font-size: 12px; }

/* ---------- 概览 ---------- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.kpi { background: #fff; border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; position: relative; overflow: hidden; }
.kpi::after { content: ""; position: absolute; right: -22px; top: -22px; width: 90px; height: 90px; border-radius: 50%; background: var(--primary-light); }
.kpi-value { font-size: 28px; font-weight: 700; margin-top: 6px; position: relative; z-index: 1; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-icon { position: absolute; right: 16px; top: 16px; font-size: 20px; color: var(--primary); z-index: 1; }
.quick-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- 模态框 / Toast ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.5); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; box-shadow: 0 24px 70px rgba(0,0,0,.25); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid var(--line); font-size: 16px; font-weight: 700; display: flex; justify-content: space-between; align-items: center; }
.modal-close { background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 20px 22px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-item { display: flex; flex-direction: column; gap: 6px; }
.form-item.full { grid-column: 1 / -1; }
.form-item label { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }
.code-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 9px; padding: 14px; max-height: 280px; overflow-y: auto; font-family: ui-monospace, Consolas, monospace; font-size: 13px; line-height: 1.9; user-select: all; }
.toast-root { position: fixed; right: 24px; top: 24px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #1e293b; color: #fff; padding: 12px 18px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13px; animation: slidein .2s ease; max-width: 360px; }
.toast.success { background: #15803d; }
.toast.error { background: #b91c1c; }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@media (max-width: 900px) {
  .sidebar { width: 64px; }
  .brand span:last-child, .nav-item span:last-child, .sidebar-footer { display: none; }
  .main { margin-left: 64px; }
  .nav-item { justify-content: center; }
}
