/* ============ 基础 ============ */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --brand: #4361ee;
  --brand-dark: #3448c5;
  --brand-soft: #eef1fe;
  --bg: #f4f6fb;
  --panel: #ffffff;
  --line: #e6e9f2;
  --line-soft: #f0f2f8;
  --text: #1c2233;
  --text-2: #4a5468;
  --muted: #8590a6;
  --green: #16a34a;
  --green-soft: #e7f7ee;
  --red: #e11d48;
  --red-soft: #fdeaee;
  --amber: #e08c00;
  --amber-soft: #fdf4e3;
  --blue-soft: #e8f1ff;
  --radius: 12px;
  --shadow-sm: 0 1px 2px rgba(20, 30, 60, .05);
  --shadow: 0 4px 16px rgba(20, 30, 60, .07);
  --shadow-lg: 0 20px 60px rgba(20, 30, 60, .14);
}

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

a { color: var(--brand); text-decoration: none; }
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cdd3e2; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #b3bbd0; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 登录 ============ */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(900px 500px at 15% -10%, #dfe6ff 0%, transparent 60%),
    radial-gradient(800px 600px at 100% 110%, #e3f0ff 0%, transparent 55%),
    var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 34px 32px 28px;
  box-shadow: var(--shadow-lg);
}
.login-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 26px; }
.login-brand h1 { font-size: 20px; letter-spacing: .5px; }
.login-brand p { color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.logo-mark {
  width: 44px; height: 44px; border-radius: 13px; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #5b76f7, #3b52d6);
  color: #fff; font-weight: 700; font-size: 19px;
  box-shadow: 0 6px 16px rgba(67, 97, 238, .35);
}
.login-form label { display: block; margin-bottom: 15px; }
.login-form label span {
  display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 500;
}
.login-form input {
  width: 100%; height: 42px; padding: 0 13px;
  border: 1px solid var(--line); border-radius: 10px;
  background: #fbfcfe; outline: none; transition: .16s;
}
.login-form input:focus {
  border-color: var(--brand); background: #fff;
  box-shadow: 0 0 0 3px rgba(67, 97, 238, .12);
}
.login-hint { text-align: center; color: var(--muted); font-size: 12px; margin-top: 14px; }
.login-form .btn { margin-top: 6px; height: 44px; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 218px; flex: none;
  background: #fff;
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; font-weight: 700; font-size: 15.5px;
  border-bottom: 1px solid var(--line-soft);
}
.sidebar-brand .logo-mark { width: 34px; height: 34px; border-radius: 10px; font-size: 15px; }

.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { padding: 14px 10px 6px; font-size: 11px; letter-spacing: .8px; color: var(--muted); font-weight: 600; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; border-radius: 9px; cursor: pointer;
  color: var(--text-2); font-size: 13.5px; font-weight: 500;
  transition: .14s; margin-bottom: 2px; user-select: none;
}
.nav-item svg { width: 17px; height: 17px; opacity: .75; flex: none; }
.nav-item:hover { background: #f5f7fc; color: var(--text); }
.nav-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.nav-item.active svg { opacity: 1; }
.nav-item .dot {
  margin-left: auto; background: var(--red); color: #fff;
  font-size: 10.5px; font-weight: 600; min-width: 17px; height: 17px;
  border-radius: 9px; display: grid; place-items: center; padding: 0 5px;
}
.nav-item .nav-ext {
  margin-left: auto; font-style: normal; font-size: 11px;
  color: #c2c8d6; line-height: 1;
}
.nav-item:hover .nav-ext { color: var(--brand); }

.sidebar-foot { border-top: 1px solid var(--line-soft); padding: 12px 14px 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.user-meta { min-width: 0; }
.user-meta strong { display: block; font-size: 13px; font-weight: 600; }
.user-meta small { color: var(--muted); font-size: 11.5px; }
.link-btn {
  background: none; border: 0; padding: 4px 0; cursor: pointer;
  color: var(--muted); font-size: 12.5px;
}
.link-btn:hover { color: var(--red); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 62px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 26px; background: rgba(255,255,255,.82);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: baseline; gap: 12px; }
.topbar h2 { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.page-sub { color: var(--muted); font-size: 12.5px; }
.clock { color: var(--muted); font-size: 12.5px; font-variant-numeric: tabular-nums; }
.view { padding: 22px 26px 60px; flex: 1; }

/* ============ 卡片 ============ */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: 16px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-head .sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 8px; }
.card-body { padding: 18px; }
.card-body.tight { padding: 0; }

.grid-2 { display: grid; grid-template-columns: 1.55fr 1fr; gap: 16px; align-items: start; }
.grid-2e { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }

/* ============ 统计卡 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; right: -30px; top: -30px;
  width: 90px; height: 90px; border-radius: 50%; background: var(--brand-soft); opacity: .55;
}
.stat .label { color: var(--muted); font-size: 12.5px; display: flex; align-items: center; gap: 6px; }
.stat .value {
  font-size: 25px; font-weight: 700; margin-top: 8px; letter-spacing: -.4px;
  font-variant-numeric: tabular-nums; position: relative; z-index: 1;
}
.stat .value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.stat .foot { margin-top: 6px; font-size: 12px; color: var(--muted); position: relative; z-index: 1; }
.delta-up { color: var(--red); font-weight: 600; }
.delta-down { color: var(--green); font-weight: 600; }

/* ============ 按钮 ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 34px; padding: 0 14px; border-radius: 9px;
  border: 1px solid var(--line); background: #fff; color: var(--text-2);
  font-size: 13px; font-weight: 500; cursor: pointer; transition: .15s;
  white-space: nowrap; user-select: none;
}
.btn:hover { border-color: #cfd6e6; background: #fafbff; color: var(--text); }
.btn:active { transform: translateY(.5px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary {
  background: var(--brand); border-color: var(--brand); color: #fff;
  box-shadow: 0 2px 8px rgba(67, 97, 238, .24);
}
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-danger { color: var(--red); border-color: #f4c6d1; background: #fff; }
.btn-danger:hover { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #f4f6fb; border-color: transparent; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-block { width: 100%; display: flex; }
.btn-link {
  background: none; border: 0; padding: 0 6px; height: auto;
  color: var(--brand); font-size: 12.5px; cursor: pointer;
}
.btn-link:hover { text-decoration: underline; }
.btn-link.danger { color: var(--red); }

/* ============ 表单 ============ */
.toolbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.input, .select, .textarea {
  height: 34px; padding: 0 11px; border: 1px solid var(--line);
  border-radius: 9px; background: #fff; outline: none; transition: .15s;
  min-width: 0;
}
.textarea { height: auto; padding: 9px 11px; resize: vertical; line-height: 1.6; }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(67, 97, 238, .1);
}
.input::placeholder { color: #aeb6c8; }
.search-box { position: relative; }
.search-box .input { padding-left: 32px; width: 220px; }
.search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--muted);
}

.field { margin-bottom: 15px; }
.field > label { display: block; font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field > label .req { color: var(--red); margin-left: 2px; }
.field .input, .field .select, .field .textarea { width: 100%; }
.field .hint { color: var(--muted); font-size: 11.5px; margin-top: 5px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.checkbox { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; }

/* ============ 表格 ============ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th {
  text-align: left; padding: 10px 14px; font-weight: 600; font-size: 12.5px;
  color: var(--text-2); background: #fafbfe;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.table td {
  padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle;
}
table.table tbody tr:last-child td { border-bottom: 0; }
table.table tbody tr:hover { background: #fafbff; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.table .cell-main { display: flex; align-items: center; gap: 10px; }
.thumb {
  width: 40px; height: 40px; border-radius: 8px; object-fit: cover;
  background: #f0f2f8; flex: none; border: 1px solid var(--line-soft);
}
.thumb.lg { width: 64px; height: 64px; border-radius: 10px; }
.cell-title { font-weight: 500; }
.cell-sub { color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.money { font-variant-numeric: tabular-nums; font-weight: 600; }
.money.red { color: var(--red); }
.money.green { color: var(--green); }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }

/* ============ 徽标 ============ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  background: #f0f2f8; color: var(--text-2); white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-blue { background: var(--blue-soft); color: var(--brand); }
.badge-gray { background: #f0f2f8; color: var(--muted); }
.badge-dot::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: currentColor; display: inline-block;
}

/* ============ 分页 ============ */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-top: 1px solid var(--line-soft); gap: 12px; flex-wrap: wrap;
}
.pager .info { color: var(--muted); font-size: 12.5px; }
.pager .pages { display: flex; gap: 5px; align-items: center; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 7px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; font-size: 12.5px;
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ============ 空态 / 加载 ============ */
.empty {
  text-align: center; padding: 52px 20px; color: var(--muted); font-size: 13px;
}
.empty .ico { font-size: 34px; opacity: .5; margin-bottom: 10px; }
.skeleton {
  background: linear-gradient(90deg, #eef0f6 25%, #f6f8fc 37%, #eef0f6 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }
.spinner {
  width: 16px; height: 16px; border: 2px solid rgba(67,97,238,.22);
  border-top-color: var(--brand); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ 弹窗 ============ */
.modal-mask {
  position: fixed; inset: 0; background: rgba(20, 26, 45, .42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px 40px; z-index: 100; overflow-y: auto;
  animation: fade .18s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: #fff; border-radius: 14px; width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg); animation: pop .2s cubic-bezier(.2,.8,.3,1);
  margin-bottom: 40px;
}
@keyframes pop { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
.modal.wide { max-width: 760px; }
.modal.narrow { max-width: 400px; }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft);
}
.modal-head h3 { font-size: 15px; font-weight: 650; }
.modal-close {
  border: 0; background: none; cursor: pointer; color: var(--muted);
  font-size: 20px; line-height: 1; padding: 4px 6px; border-radius: 6px;
}
.modal-close:hover { background: #f4f6fb; color: var(--text); }
.modal-body { padding: 20px; max-height: 64vh; overflow-y: auto; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
}

/* 抽屉 */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(20, 26, 45, .4);
  z-index: 90; animation: fade .18s ease;
}
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 520px; max-width: 94vw;
  background: #fff; z-index: 91; display: flex; flex-direction: column;
  box-shadow: -12px 0 40px rgba(20, 30, 60, .16);
  animation: slideIn .24s cubic-bezier(.2,.8,.3,1);
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: none; } }
.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line-soft); flex: none;
}
.drawer-body { flex: 1; overflow-y: auto; padding: 20px; }
.drawer-foot {
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
  display: flex; gap: 10px; justify-content: flex-end; flex: none;
}

/* ============ 提示 ============ */
.toast-root {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--brand);
  padding: 10px 18px; border-radius: 10px; box-shadow: var(--shadow);
  font-size: 13px; animation: toastIn .22s ease; max-width: 420px;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--red); }
.toast.warn { border-left-color: var(--amber); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }

/* ============ 图表 ============ */
.chart-box { position: relative; width: 100%; }
.chart-box canvas { display: block; width: 100%; }
.chart-legend { display: flex; gap: 16px; font-size: 12px; color: var(--muted); }
.chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }

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

/* 列表行 */
.row-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 18px;
  border-bottom: 1px solid var(--line-soft);
}
.row-item:last-child { border-bottom: 0; }
.row-item .grow { flex: 1; min-width: 0; }

/* 标签页 */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  padding: 9px 14px; font-size: 13.5px; color: var(--text-2); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500;
  user-select: none;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* 详情描述 */
.desc-list { display: grid; grid-template-columns: 92px 1fr; gap: 9px 12px; font-size: 13px; }
.desc-list dt { color: var(--muted); }
.desc-list dd { margin: 0; }

.kv-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; }
.kv-row.total { border-top: 1px dashed var(--line); margin-top: 6px; padding-top: 12px; font-size: 15px; font-weight: 650; }

/* 工具类 */
.flex { display: flex; }
.items-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-16 { margin-top: 16px; }
.text-sm { font-size: 12.5px; }
.strong { font-weight: 600; }
.w-100 { width: 100%; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-2e { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .sidebar-brand span, .nav-group, .nav-item span, .sidebar-foot .user-meta, .sidebar-foot .link-btn { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .view { padding: 16px; }
  .topbar { padding: 0 16px; }
}
