:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --line: #e6e9ef;
  --line-soft: #f1f3f7;
  --text: #131a26;
  --text-2: #445065;
  --muted: #6b7a90;
  --muted-2: #93a0b3;
  --brand: #3556e8;
  --brand-50: #eef2ff;
  --brand-100: #dde5ff;
  --green: #0f9d6e;
  --green-50: #e8f7f1;
  --amber: #b7791f;
  --amber-50: #fdf5e6;
  --red: #d9363e;
  --red-50: #fdeded;
  --violet: #6d3fd4;
  --violet-50: #f1ecfd;
  --sky: #0b7ea8;
  --sky-50: #e7f4fa;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --sidebar-w: 216px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #ccd3df; border-radius: 6px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: #aab5c6; background-clip: content-box; }

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* ============================ 布局 ============================ */

.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: #0d1424;
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { padding: 20px 20px 16px; display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, #5a85fc, #213fdd);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700;
  box-shadow: 0 6px 16px rgba(33, 63, 221, .45);
}
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: .3px; }
.brand-sub {
  font-size: 10px; color: rgba(255, 255, 255, .38);
  letter-spacing: .16em; text-transform: uppercase; margin-top: 1px;
}

.nav { flex: 1; overflow-y: auto; padding: 4px 10px 16px; }
.nav-group { margin-bottom: 16px; }
.nav-title {
  padding: 0 12px; margin-bottom: 6px;
  font-size: 10.5px; color: rgba(255, 255, 255, .3);
  letter-spacing: .12em; text-transform: uppercase;
}
.nav-item {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 12px; border-radius: 8px;
  color: rgba(255, 255, 255, .56);
  font-size: 13px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255, 255, 255, .05); color: rgba(255, 255, 255, .92); }
.nav-item.active { background: rgba(255, 255, 255, .09); color: #fff; font-weight: 500; }
.nav-item.active::before {
  content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 3px; height: 16px; border-radius: 0 3px 3px 0; background: #5a85fc;
}
.nav-item svg { flex: 0 0 16px; opacity: .9; }
.nav-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: #d9363e; color: #fff;
  font-size: 10.5px; font-weight: 600; display: flex; align-items: center; justify-content: center;
}

.sidebar-foot {
  padding: 14px 16px; border-top: 1px solid rgba(255, 255, 255, .07);
  font-size: 11.5px; color: rgba(255, 255, 255, .45);
}
.dot-live {
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: #34d399; box-shadow: 0 0 6px #34d399; margin-right: 6px;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  height: 60px; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.topbar h1 { font-size: 17px; font-weight: 600; letter-spacing: -.2px; }
.topbar .sub { font-size: 12.5px; color: var(--muted-2); margin-left: 10px; font-weight: 400; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.content { padding: 24px 28px 40px; flex: 1; }

/* ============================ 卡片 ============================ */

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-hd {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 13px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-ti { font-size: 14px; font-weight: 600; letter-spacing: -.1px; }
.card-desc { font-size: 12px; color: var(--muted-2); margin-top: 2px; }
.card-bd { padding: 18px; }
.card-bd.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }

/* ============================ 指标卡 ============================ */

.metric { padding: 16px 18px; }
.metric-top { display: flex; align-items: flex-start; justify-content: space-between; }
.metric-label { font-size: 12.5px; color: var(--muted); }
.metric-icon {
  width: 28px; height: 28px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
}
.metric-value {
  margin-top: 6px; display: flex; align-items: baseline; gap: 4px;
  font-size: 26px; font-weight: 600; letter-spacing: -.8px; line-height: 1.1;
}
.metric-unit { font-size: 12px; color: var(--muted-2); font-weight: 400; }
.metric-hint { margin-top: 6px; font-size: 11.5px; color: var(--muted-2); }
.trend-up { color: var(--red); font-size: 11.5px; font-weight: 500; margin-left: 4px; }
.trend-down { color: var(--green); font-size: 11.5px; font-weight: 500; margin-left: 4px; }

/* ============================ 表格 ============================ */

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  text-align: left; font-weight: 500; font-size: 11.5px;
  color: var(--muted-2); letter-spacing: .04em; text-transform: uppercase;
  background: #fafbfc; padding: 9px 16px; border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
.tbl tbody td { padding: 12px 16px; border-bottom: 1px solid var(--line-soft); color: var(--text-2); }
.tbl tbody tr:hover { background: #fafbfd; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl .t-primary { color: var(--text); font-weight: 500; }
.tbl .t-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 2px; }
.t-right { text-align: right; }
.t-center { text-align: center; }
.t-nowrap { white-space: nowrap; }

/* ============================ 按钮 ============================ */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px; border-radius: 8px;
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent; transition: all .15s; white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover:not(:disabled) { background: #2a46c9; }
.btn-default { background: #fff; border-color: #dde1e9; color: var(--text-2); }
.btn-default:hover:not(:disabled) { background: #f7f8fa; border-color: #ccd3de; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover:not(:disabled) { background: #f1f3f7; color: var(--text); }
.btn-danger { background: #fff; border-color: #f3d1d1; color: var(--red); }
.btn-danger:hover:not(:disabled) { background: var(--red-50); }
.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 6px; }
.btn-xs { height: 22px; padding: 0 7px; font-size: 11.5px; border-radius: 5px; }

/* ============================ 徽章 ============================ */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 6px;
  font-size: 11.5px; font-weight: 500; white-space: nowrap;
}
.chip .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.chip-green { background: var(--green-50); color: var(--green); }
.chip-amber { background: var(--amber-50); color: var(--amber); }
.chip-red { background: var(--red-50); color: var(--red); }
.chip-slate { background: #f1f3f7; color: #64748b; }
.chip-brand { background: var(--brand-50); color: var(--brand); }
.chip-violet { background: var(--violet-50); color: var(--violet); }
.chip-sky { background: var(--sky-50); color: var(--sky); }

.tag {
  display: inline-flex; align-items: center; height: 20px; padding: 0 7px;
  border-radius: 5px; font-size: 11px; font-weight: 600; letter-spacing: .02em;
}
.tag-cpl { background: var(--brand-50); color: var(--brand); }
.tag-cpql { background: var(--violet-50); color: var(--violet); }

/* ============================ 表单 ============================ */

.input, .select {
  height: 34px; padding: 0 10px; border-radius: 8px;
  border: 1px solid #dde1e9; background: #fff; font-size: 13px; color: var(--text);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: #8eb0ff; box-shadow: 0 0 0 3px var(--brand-50); }
.input::placeholder { color: var(--muted-2); }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ============================ 标签页 ============================ */

.tabs { display: flex; align-items: center; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line-soft); }
.tab {
  position: relative; height: 38px; padding: 0 12px; display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--muted); transition: color .15s;
}
.tab:hover { color: var(--text-2); }
.tab.active { color: var(--brand); font-weight: 500; }
.tab.active::after {
  content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px;
  height: 2px; border-radius: 2px; background: var(--brand);
}
.tab .cnt { font-size: 11px; color: var(--muted-2); }

/* ============================ 进度 ============================ */

.bar { height: 5px; border-radius: 3px; background: #eef1f6; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 3px; background: var(--brand); transition: width .35s; }
.bar.green > i { background: var(--green); }
.bar.amber > i { background: #e0a020; }
.bar.red > i { background: var(--red); }

/* ============================ 提示条 ============================ */

.notice {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 18px; border-radius: var(--radius);
  border: 1px solid var(--brand-100);
  background: linear-gradient(90deg, #f2f5ff, #fff);
}
.notice-icon {
  width: 26px; height: 26px; border-radius: 8px; flex: 0 0 26px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.notice-title { font-size: 13px; font-weight: 600; }
.notice-body { font-size: 12.5px; color: var(--muted); margin-top: 2px; line-height: 1.65; }
.notice-body b { color: var(--text-2); }

/* ============================ 空状态 ============================ */

.empty { padding: 56px 20px; text-align: center; }
.empty-icon {
  width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px;
  background: #f2f4f8; color: #b9c3d2;
  display: flex; align-items: center; justify-content: center;
}
.empty-title { font-size: 13.5px; font-weight: 500; color: var(--text-2); }
.empty-desc { font-size: 12.5px; color: var(--muted-2); margin-top: 4px; }

/* ============================ 图表 ============================ */

.chart-wrap { position: relative; width: 100%; }
.legend { display: flex; align-items: center; gap: 16px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.legend i { display: inline-block; width: 14px; height: 2px; margin-right: 6px; vertical-align: middle; }
.legend i.dash {
  background: repeating-linear-gradient(to right, currentColor 0 4px, transparent 4px 7px);
}

.donut-legend { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 0; }
.donut-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.donut-row .sw { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 8px; }
.donut-row .nm { flex: 1; color: var(--muted); }
.donut-row .vl { font-weight: 500; color: var(--text); }
.donut-row .pc { width: 42px; text-align: right; color: var(--muted-2); }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar-row { display: flex; align-items: center; gap: 10px; }
.hbar-name { width: 84px; flex: 0 0 84px; font-size: 12px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { flex: 1; height: 18px; background: #f4f6fa; border-radius: 5px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 5px; background: var(--brand); transition: width .4s; }
.hbar-val { width: 56px; text-align: right; font-size: 12px; font-weight: 500; }

.hourbars { display: flex; align-items: flex-end; gap: 3px; height: 84px; }
.hourbar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; }
.hourbar-track { width: 100%; flex: 1; display: flex; align-items: flex-end; }
.hourbar-fill { width: 100%; border-radius: 3px 3px 0 0; background: #c3d0f8; transition: background .15s; min-height: 3px; }
.hourbar:hover .hourbar-fill { background: var(--brand); }
.hourbar-label { font-size: 9.5px; color: var(--muted-2); }

/* ============================ 其他 ============================ */

.section-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.divider { height: 1px; background: var(--line-soft); margin: 14px 0; }
.muted { color: var(--muted); }
.muted-2 { color: var(--muted-2); }
.small { font-size: 12px; }
.xsmall { font-size: 11.5px; }
.strong { font-weight: 600; color: var(--text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; }
.mt4 { margin-top: 4px; } .mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; } .gap16 { gap: 16px; }
.grow { flex: 1; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}

.alert-row { display: flex; gap: 10px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); }
.alert-row:last-child { border-bottom: 0; }
.alert-row:hover { background: #fafbfd; }
.alert-dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 6px; flex: 0 0 6px; }
.alert-dot.critical { background: var(--red); box-shadow: 0 0 0 3px var(--red-50); }
.alert-dot.warning { background: #e0a020; box-shadow: 0 0 0 3px var(--amber-50); }
.alert-dot.info { background: var(--sky); box-shadow: 0 0 0 3px var(--sky-50); }

.kv { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 7px 0; }
.kv-k { font-size: 12.5px; color: var(--muted); flex: 0 0 auto; }
.kv-v { font-size: 13px; text-align: right; color: var(--text-2); }

.code-block {
  background: #0f1626; color: #cbd5e1; border-radius: 10px;
  padding: 14px 16px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px; line-height: 1.7; overflow-x: auto; white-space: pre;
}

/* 骨架 */
.sk { background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 37%, #eef1f5 63%); background-size: 400% 100%; animation: shimmer 1.3s infinite; border-radius: 6px; }
@keyframes shimmer { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

.fade { animation: fade .26s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }

/* 加载条 */
.loading-bar {
  position: fixed; top: 0; left: var(--sidebar-w); right: 0; height: 2px; z-index: 100;
  background: linear-gradient(90deg, transparent, var(--brand), transparent);
  animation: slide 1s infinite;
}
@keyframes slide { 0% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }

/* Toast */
.toast-wrap { position: fixed; top: 18px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  min-width: 240px; max-width: 380px; padding: 11px 14px; border-radius: 10px;
  background: #131a26; color: #fff; font-size: 13px; box-shadow: 0 10px 30px rgba(0,0,0,.18);
  display: flex; align-items: flex-start; gap: 8px;
  animation: toastIn .2s ease both;
}
.toast.err { background: #b02a30; }
.toast.ok { background: #0f6f52; }
@keyframes toastIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

/* 响应式 */
@media (max-width: 1280px) {
  .g5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 980px) {
  .sidebar { position: fixed; z-index: 90; transform: translateX(-100%); transition: transform .22s; }
  .sidebar.open { transform: none; }
  .loading-bar { left: 0; }
  .g5, .g4, .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .span2 { grid-column: span 2; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
@media (max-width: 640px) {
  .g5, .g4, .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: span 1; }
  .topbar .sub { display: none; }
}

/* ============================ 补充：模块页通用元素 ============================ */

.mb6 { margin-bottom: 6px; }
.gap6 { gap: 6px; }
.between { justify-content: space-between; }
.tr { text-align: right; }
.strong { font-weight: 600; color: var(--text); }

.bar.tiny { height: 3px; margin-top: 5px; border-radius: 2px; }

.tab-n {
  font-size: 10.5px; color: var(--muted-2);
  background: var(--line-soft); border-radius: 8px; padding: 1px 6px; line-height: 1.6;
}
.tab.active .tab-n { background: var(--brand-50); color: var(--brand); }

.tbl-sm th, .tbl-sm td { padding: 6px 9px; font-size: 12px; }

.input-sm { height: 28px; padding: 0 8px; font-size: 12px; border-radius: 7px; }

.form-row {
  display: flex; gap: 16px; padding: 12px 0;
  border-bottom: 1px solid var(--line-soft);
}
.form-row:last-child { border-bottom: 0; padding-bottom: 0; }
.form-label {
  flex: 0 0 132px; font-size: 12.5px; color: var(--text-2);
  font-weight: 500; padding-top: 6px;
}
.form-control { flex: 1; min-width: 0; }

.tbl tfoot td {
  background: #fafbfd; font-weight: 600; color: var(--text);
  border-top: 1px solid var(--line);
}

.agent-row { cursor: pointer; }
.agent-row:hover { background: #fbfcfe; }
