:root {
  --blue: #3b82f6;
  --blue-d: #2563eb;
  --purple: #8b5cf6;
  --green: #10b981;
  --orange: #f59e0b;
  --red: #ef4444;
  --cyan: #06b6d4;
  --pink: #ec4899;
  --t1: #1f2937;
  --t2: #6b7280;
  --t3: #9ca3af;
  --bd: #e5e7eb;
  --bd-l: #f0f0f4;
  --bg: #f4f6f9;
  --panel: #ffffff;
  --side: #111827;
  --side-hover: #1f2937;
  --side-active: #2563eb;
  --r: 8px;
  --r-sm: 6px;
  --sh: 0 1px 3px rgba(0, 0, 0, .05);
  --sh-md: 0 4px 16px rgba(0, 0, 0, .08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--t1);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--blue); text-decoration: none; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }
::-webkit-scrollbar-track { background: transparent; }

/* ============ 布局 ============ */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 208px;
  background: var(--side);
  color: #cbd5e1;
  flex: 0 0 208px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 20;
}

.sidebar .brand {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .5px;
}

.sidebar .brand .logo {
  width: 26px; height: 26px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: #fff; font-weight: 700;
}

.nav { padding: 10px 8px; flex: 1; overflow-y: auto; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px;
  border-radius: var(--r-sm);
  cursor: pointer;
  color: #cbd5e1;
  font-size: 14px;
  margin-bottom: 2px;
  user-select: none;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: var(--side-hover); color: #fff; }
.nav-item.active { background: var(--side-active); color: #fff; font-weight: 500; }
.nav-item .ico { width: 18px; text-align: center; font-size: 15px; opacity: .9; }

.nav-group {
  padding: 14px 14px 6px;
  font-size: 11px;
  color: #64748b;
  letter-spacing: 1px;
}

.sidebar .foot {
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 12px;
  color: #64748b;
}

.main { flex: 1; margin-left: 208px; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 56px;
  background: #fff;
  border-bottom: 1px solid var(--bd);
  display: flex; align-items: center; gap: 12px;
  padding: 0 20px;
  position: sticky; top: 0; z-index: 15;
}

.topbar .title { font-size: 15px; font-weight: 600; }
.topbar .spacer { flex: 1; }

.content { padding: 18px 20px 40px; flex: 1; }

/* ============ 表单控件 ============ */
.sel, .inp {
  height: 34px;
  border: 1px solid var(--bd);
  border-radius: var(--r-sm);
  background: #fff;
  padding: 0 30px 0 10px;
  font-size: 13px;
  color: var(--t1);
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8.5L1.5 4h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  cursor: pointer;
  min-width: 92px;
}
.sel:focus, .inp:focus { border-color: var(--blue); }
.inp { background-image: none; padding: 0 10px; min-width: 130px; cursor: text; }

input[type=date].inp { padding-right: 6px; min-width: 138px; }

.btn {
  height: 34px; padding: 0 14px;
  border: 1px solid var(--bd);
  background: #fff;
  border-radius: var(--r-sm);
  font-size: 13px;
  color: var(--t1);
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: #c7cbd1; background: #fafafa; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-d); border-color: var(--blue-d); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

.quick-range { display: flex; gap: 0; border: 1px solid var(--bd); border-radius: var(--r-sm); overflow: hidden; }
.quick-range button {
  border: none; background: #fff; padding: 0 11px; height: 32px;
  font-size: 12px; color: var(--t2); cursor: pointer; border-right: 1px solid var(--bd-l);
}
.quick-range button:last-child { border-right: none; }
.quick-range button:hover { background: #f3f4f6; }
.quick-range button.on { background: var(--blue); color: #fff; }

/* ============ 卡片指标 ============ */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--bd-l);
  border-radius: var(--r);
  padding: 14px 16px;
  box-shadow: var(--sh);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--blue);
}
.card.c-green::before { background: var(--green); }
.card.c-orange::before { background: var(--orange); }
.card.c-purple::before { background: var(--purple); }
.card.c-cyan::before { background: var(--cyan); }
.card.c-red::before { background: var(--red); }

.card .label { font-size: 12.5px; color: var(--t2); margin-bottom: 7px; display: flex; align-items: center; gap: 5px; }
.card .value { font-size: 25px; font-weight: 600; line-height: 1.15; letter-spacing: -.5px; }
.card .value small { font-size: 13px; font-weight: 400; color: var(--t2); margin-left: 2px; }
.card .sub { margin-top: 7px; font-size: 12px; color: var(--t3); display: flex; align-items: center; gap: 5px; }

.trend { display: inline-flex; align-items: center; font-size: 12px; }
.trend.up { color: var(--green); }
.trend.down { color: var(--red); }
.trend.flat { color: var(--t3); }

/* ============ 面板 ============ */
.panel {
  background: var(--panel);
  border: 1px solid var(--bd-l);
  border-radius: var(--r);
  box-shadow: var(--sh);
  margin-bottom: 14px;
  overflow: hidden;
}
.panel-hd {
  height: 44px;
  padding: 0 16px;
  display: flex; align-items: center; gap: 8px;
  border-bottom: 1px solid var(--bd-l);
  font-size: 14px; font-weight: 600;
}
.panel-hd .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--blue); display: inline-block; }
.panel-hd .spacer { flex: 1; }
.panel-hd .tip { font-size: 12px; color: var(--t3); font-weight: 400; }
.panel-bd { padding: 14px 16px; }
.panel-bd.flush { padding: 0; }

.grid { display: grid; gap: 14px; }
.grid.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.g32 { grid-template-columns: 2fr 1fr; }

@media (max-width: 1100px) {
  .grid.g2, .grid.g3, .grid.g32 { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  .sidebar { width: 60px; flex-basis: 60px; }
  .sidebar .nav-item span.txt, .sidebar .brand .btxt, .sidebar .foot { display: none; }
  .sidebar .nav-group { display: none; }
  .main { margin-left: 60px; }
}

/* ============ 表格 ============ */
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left; font-weight: 500; color: var(--t2);
  padding: 9px 16px; background: #fafbfc; border-bottom: 1px solid var(--bd-l);
  font-size: 12.5px; white-space: nowrap;
}
.table td { padding: 9px 16px; border-bottom: 1px solid var(--bd-l); vertical-align: middle; }
.table tbody tr:hover td { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: none; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .path { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.table .muted { color: var(--t3); }

.rank-no {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 5px; background: #f1f5f9;
  color: var(--t2); font-size: 12px;
}
.rank-no.top { background: var(--blue); color: #fff; }

/* ============ 条形列表 ============ */
.bar-list { display: flex; flex-direction: column; gap: 2px; }
.bar-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 0; font-size: 13px;
}
.bar-item .nm {
  flex: 0 0 38%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--t1);
}
.bar-item .track { flex: 1; height: 18px; background: #f1f5f9; border-radius: 4px; overflow: hidden; min-width: 60px; }
.bar-item .fill { height: 100%; border-radius: 4px; transition: width .5s ease; background: var(--blue); }
.bar-item .vv { flex: 0 0 auto; min-width: 78px; text-align: right; color: var(--t2); font-variant-numeric: tabular-nums; font-size: 12.5px; }
.bar-item .vv b { color: var(--t1); font-weight: 600; }

/* ============ 图表 ============ */
.chart { width: 100%; position: relative; }
.chart svg { display: block; width: 100%; }
.legend { display: flex; gap: 14px; align-items: center; font-size: 12px; color: var(--t2); padding: 2px 0 8px; }
.legend i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; }

.tip-box {
  position: absolute; pointer-events: none; z-index: 30;
  background: rgba(17, 24, 39, .94); color: #fff;
  border-radius: var(--r-sm); padding: 8px 10px; font-size: 12px; line-height: 1.7;
  white-space: nowrap; opacity: 0; transition: opacity .1s;
  box-shadow: var(--sh-md);
}
.tip-box.show { opacity: 1; }
.tip-box .t { color: #cbd5e1; margin-bottom: 3px; font-size: 11.5px; }
.tip-box .row { display: flex; align-items: center; gap: 6px; }
.tip-box .row i { width: 8px; height: 8px; border-radius: 2px; }
.tip-box .row b { margin-left: auto; padding-left: 12px; }

.donut-wrap { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.donut-legend { flex: 1; min-width: 110px; display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; }
.donut-legend .dl { display: flex; align-items: center; gap: 7px; }
.donut-legend .dl i { width: 9px; height: 9px; border-radius: 2px; flex: 0 0 9px; }
.donut-legend .dl .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend .dl .vv { color: var(--t2); }

/* ============ 杂项 ============ */
.badge {
  display: inline-block; padding: 1px 7px; border-radius: 20px;
  font-size: 11.5px; line-height: 18px; background: #f1f5f9; color: var(--t2);
}
.badge.b { background: #eff6ff; color: var(--blue-d); }
.badge.g { background: #ecfdf5; color: #047857; }
.badge.o { background: #fffbeb; color: #b45309; }
.badge.r { background: #fef2f2; color: #b91c1c; }
.badge.p { background: #f5f3ff; color: #6d28d9; }

.empty { text-align: center; padding: 42px 10px; color: var(--t3); font-size: 13px; }
.empty .ico { font-size: 30px; display: block; margin-bottom: 8px; opacity: .35; }

.loading { text-align: center; padding: 40px; color: var(--t3); font-size: 13px; }
.spin {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid #e5e7eb; border-top-color: var(--blue);
  border-radius: 50%; animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast-wrap { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 999; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: rgba(17, 24, 39, .92); color: #fff; padding: 9px 16px;
  border-radius: var(--r-sm); font-size: 13px; box-shadow: var(--sh-md);
  animation: fadeIn .2s ease;
}
.toast.ok { background: #047857; }
.toast.err { background: #b91c1c; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.section-title { font-size: 13px; color: var(--t2); margin: 2px 0 10px; }

/* 登录页 */
.login-page {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 45%, #7c3aed 100%);
  padding: 20px;
}
.login-box {
  width: 100%; max-width: 372px;
  background: #fff; border-radius: 14px; padding: 34px 32px 26px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, .22);
}
.login-box h1 { margin: 0 0 4px; font-size: 21px; text-align: center; }
.login-box .sub2 { text-align: center; color: var(--t2); font-size: 13px; margin-bottom: 22px; }
.login-box .field { margin-bottom: 14px; }
.login-box .field label { display: block; font-size: 12.5px; color: var(--t2); margin-bottom: 6px; }
.login-box .field .inp { width: 100%; height: 40px; }
.login-box .btn { width: 100%; height: 40px; font-size: 14px; }
.login-box .err { color: var(--red); font-size: 12.5px; min-height: 18px; margin: 4px 0 8px; text-align: center; }
.login-box .brand-line { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 14px; }
.login-box .brand-line .logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700;
}

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(17, 24, 39, .45);
  display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal {
  background: #fff; border-radius: 10px; width: 100%; max-width: 460px; box-shadow: var(--sh-md);
  animation: pop .16s ease;
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-hd { padding: 15px 18px; border-bottom: 1px solid var(--bd-l); font-size: 15px; font-weight: 600; display: flex; align-items: center; }
.modal-hd .spacer { flex: 1; }
.modal-hd .x { cursor: pointer; color: var(--t3); font-size: 18px; line-height: 1; padding: 0 4px; }
.modal-bd { padding: 18px; }
.modal-ft { padding: 12px 18px; border-top: 1px solid var(--bd-l); display: flex; justify-content: flex-end; gap: 8px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--t2); margin-bottom: 6px; }
.form-row .inp { width: 100%; }

.code-box {
  background: #0f172a; color: #e2e8f0; border-radius: var(--r-sm);
  padding: 13px 14px; font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 12.5px; line-height: 1.75; overflow-x: auto; white-space: pre; margin: 0;
}
.code-box .hl { color: #fbbf24; }

.user-menu { position: relative; }
.user-menu .avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--blue); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; user-select: none;
}
.dropdown {
  position: absolute; right: 0; top: 38px; background: #fff; border: 1px solid var(--bd);
  border-radius: var(--r-sm); box-shadow: var(--sh-md); min-width: 132px; overflow: hidden; display: none;
}
.dropdown.show { display: block; }
.dropdown .item { padding: 9px 13px; font-size: 13px; cursor: pointer; color: var(--t1); }
.dropdown .item:hover { background: #f3f4f6; }

.rt-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); display: inline-block; box-shadow: 0 0 0 0 rgba(16, 185, 129, .7); animation: pulse 1.6s infinite; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, .6); }
  70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
  100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.kv { display: flex; gap: 6px; font-size: 12.5px; color: var(--t2); flex-wrap: wrap; }
.kv span b { color: var(--t1); font-weight: 600; }
