:root {
  --bg: #0b0f17;
  --bg-2: #111725;
  --bg-3: #161e2f;
  --line: #1f2b41;
  --line-2: #2a3a55;
  --txt: #e6edf7;
  --txt-2: #8fa3bf;
  --txt-3: #5d7091;
  --acc: #3b82f6;
  --acc-2: #2563eb;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --purple: #8b5cf6;
  --radius: 10px;
  --glass: rgba(17, 23, 37, .72);
  --glass-line: rgba(255, 255, 255, .08);
}

/* ---------------- 浅色主题 ---------------- */
[data-theme="light"] {
  --bg: #f5f7fb;
  --bg-2: #ffffff;
  --bg-3: #eef2f7;
  --line: #e4e9f0;
  --line-2: #d3dae5;
  --txt: #16202f;
  --txt-2: #56617a;
  --txt-3: #8b96a8;
  --acc: #2563eb;
  --acc-2: #1d4ed8;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --glass: rgba(255, 255, 255, .78);
  --glass-line: rgba(0, 0, 0, .06);
}
[data-theme="light"] body { background: var(--bg); }
[data-theme="light"] thead th { background: #f0f4f9; }
[data-theme="light"] tbody tr:hover { background: #f6f9fd; }
[data-theme="light"] .sidebar { background: var(--bg-2); }
[data-theme="light"] .topbar { background: #fff; }
[data-theme="light"] .table-wrap { background: #fff; }
[data-theme="light"] .drawer { background: #fff; }
[data-theme="light"] a.card.drill:hover { background: linear-gradient(180deg, #f8fbff 0%, #fff 100%); }
[data-theme="light"] .toast { background: #fff; box-shadow: 0 8px 28px rgba(0,0,0,.12); }
[data-theme="light"] .kv { border-bottom-color: #eef2f7; }
[data-theme="light"] .nav-item:hover { background: #eef2f7; }
[data-theme="light"] .nav-item.active { background: rgba(37,99,235,.1); color: #1d4ed8; }
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--txt);
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--acc); text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------------- 登录 ---------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12px; color: var(--txt-2); margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; background: var(--bg-3); color: var(--txt);
  border: 1px solid var(--line-2); border-radius: 8px; outline: none; font-size: 13px;
  box-sizing: border-box;
}
.field input:focus { border-color: var(--acc); }

.login-wrap {
  height: 100vh; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; background: #070a11;
}
/* 极光背景 */
.aurora { position: absolute; inset: -20%; z-index: 0; filter: blur(80px); opacity: .85; }
.aurora span {
  position: absolute; border-radius: 50%; mix-blend-mode: screen;
  animation: drift 22s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) { width: 46vw; height: 46vw; left: -6%; top: -12%; background: #2563eb; animation-delay: 0s; }
.aurora span:nth-child(2) { width: 38vw; height: 38vw; right: -4%; top: 8%; background: #7c3aed; animation-delay: -6s; }
.aurora span:nth-child(3) { width: 34vw; height: 34vw; left: 22%; bottom: -14%; background: #059669; animation-delay: -12s; }
.aurora span:nth-child(4) { width: 26vw; height: 26vw; right: 18%; bottom: 4%; background: #0891b2; animation-delay: -18s; }
@keyframes drift {
  0%   { transform: translate3d(0,0,0) scale(1); }
  50%  { transform: translate3d(4vw,-3vh,0) scale(1.12); }
  100% { transform: translate3d(-3vw,4vh,0) scale(.95); }
}
/* 网格纹理 */
.login-grid {
  position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background-image: linear-gradient(rgba(255,255,255,.045) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(255,255,255,.045) 1px, transparent 1px);
  background-size: 46px 46px;
  mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
  -webkit-mask-image: radial-gradient(circle at 50% 45%, #000 0%, transparent 72%);
}

.login-card {
  position: relative; z-index: 2;
  width: 400px; padding: 40px 36px;
  background: rgba(13, 18, 30, .72);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  box-shadow: 0 32px 80px rgba(0,0,0,.55), inset 0 1px 0 rgba(255,255,255,.08);
  animation: cardIn .6s cubic-bezier(.2,.8,.2,1);
  color: #e6edf7;
}
@keyframes cardIn { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }

.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.login-mark {
  width: 42px; height: 42px; border-radius: 12px; flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 700; color: #fff;
  box-shadow: 0 8px 24px rgba(59,130,246,.45);
}
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: .5px; margin: 0; }
.login-card .sub { color: #8fa3bf; font-size: 12px; margin-bottom: 30px; margin-top: 4px; }

.login-card .field label { color: #8fa3bf; }
.login-card .field input {
  background: rgba(255,255,255,.055); border: 1px solid rgba(255,255,255,.11); color: #e6edf7;
  padding: 11px 13px; border-radius: 10px;
}
.login-card .field input:focus { border-color: rgba(99,102,241,.75); background: rgba(255,255,255,.09); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.login-card .btn.primary {
  background: linear-gradient(135deg, #3b82f6, #6366f1);
  border: none; padding: 12px; border-radius: 10px; font-weight: 600; letter-spacing: 1px;
  box-shadow: 0 8px 26px rgba(59,130,246,.35);
}
.login-card .btn.primary:hover { filter: brightness(1.08); }

.login-foot { margin-top: 18px; font-size: 11px; color: #5d7091; text-align: center; }
.login-tools { position: absolute; top: 22px; right: 26px; z-index: 3; display: flex; gap: 8px; }
.theme-btn {
  width: 34px; height: 34px; border-radius: 9px; border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06); color: #cfd8e8; cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(10px);
  transition: .15s;
}
.theme-btn:hover { background: rgba(255,255,255,.13); transform: translateY(-1px); }

/* 浅色下的登录页 */
[data-theme="light"] .login-wrap { background: #eef2f8; }
[data-theme="light"] .aurora { opacity: .55; }
[data-theme="light"] .aurora span { mix-blend-mode: multiply; }
[data-theme="light"] .login-grid { background-image: linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px), linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px); }
[data-theme="light"] .login-card {
  background: rgba(255,255,255,.86); color: #16202f;
  border-color: rgba(0,0,0,.06); box-shadow: 0 30px 70px rgba(30,50,90,.16);
}
[data-theme="light"] .login-card .sub { color: #56617a; }
[data-theme="light"] .login-card .field label { color: #56617a; }
[data-theme="light"] .login-card .field input { background: #f4f7fc; border-color: #dde4ee; color: #16202f; }
[data-theme="light"] .login-foot { color: #8b96a8; }
[data-theme="light"] .theme-btn { border-color: rgba(0,0,0,.1); background: rgba(255,255,255,.8); color: #56617a; }

.btn {
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line-2);
  background: var(--bg-3); color: var(--txt); font-size: 13px; transition: .15s;
}
.btn:hover { background: #1c2740; border-color: #35507a; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--acc-2); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.full { width: 100%; padding: 11px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.err { color: var(--red); font-size: 12px; min-height: 18px; margin-top: 10px; }

/* ---------------- 布局 ---------------- */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 210px; flex-shrink: 0; background: var(--bg-2);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
}
.logo {
  height: 56px; display: flex; align-items: center; gap: 9px; padding: 0 18px;
  border-bottom: 1px solid var(--line); font-weight: 650; font-size: 15px; letter-spacing: .3px;
}
.logo .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.nav { flex: 1; overflow-y: auto; padding: 12px 10px; }
.nav-group { font-size: 10.5px; color: var(--txt-3); text-transform: uppercase; letter-spacing: .8px; padding: 14px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 9px; padding: 8px 10px; border-radius: 7px;
  color: var(--txt-2); font-size: 13px; cursor: pointer; user-select: none; transition: .12s;
}
.nav-item:hover { background: var(--bg-3); color: var(--txt); }
.nav-item.active { background: rgba(59,130,246,.14); color: #9dc1ff; }
.nav-item .ic { width: 15px; text-align: center; opacity: .9; font-size: 13px; }
.sidebar-foot { padding: 12px 16px; border-top: 1px solid var(--line); font-size: 11px; color: var(--txt-3); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; border-bottom: 1px solid var(--line); background: var(--bg);
}
.topbar .crumb { font-size: 14px; font-weight: 600; }
.topbar .right { display: flex; align-items: center; gap: 14px; font-size: 12px; color: var(--txt-2); }
.badge { padding: 2px 8px; border-radius: 20px; font-size: 11px; border: 1px solid var(--line-2); }
.badge.ok { color: var(--green); border-color: rgba(16,185,129,.35); background: rgba(16,185,129,.1); }
.badge.warn { color: var(--amber); border-color: rgba(245,158,11,.35); background: rgba(245,158,11,.1); }
.badge.bad { color: var(--red); border-color: rgba(239,68,68,.35); background: rgba(239,68,68,.1); }
.badge.mute { color: var(--txt-3); }

.content { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }

/* ---------------- 卡片 / 网格 ---------------- */
.grid { display: grid; gap: 14px; }
.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)); }
@media (max-width: 1200px) { .g4 { grid-template-columns: repeat(2,minmax(0,1fr)); } .g3, .g2 { grid-template-columns: 1fr; } }

.card {
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
}
.card h3 { font-size: 13px; font-weight: 600; color: var(--txt-2); margin-bottom: 12px; }
.kpi-label { font-size: 12px; color: var(--txt-3); margin-bottom: 8px; }
.kpi-val { font-size: 24px; font-weight: 650; letter-spacing: -.5px; }
.kpi-sub { font-size: 11.5px; color: var(--txt-3); margin-top: 6px; }
.kpi-val.green { color: var(--green); }
.kpi-val.amber { color: var(--amber); }
.kpi-val.red { color: var(--red); }
.kpi-val.blue { color: #60a5fa; }

.bar { height: 5px; border-radius: 3px; background: var(--bg-3); overflow: hidden; margin-top: 10px; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--acc), #60a5fa); }
.bar.warn > i { background: linear-gradient(90deg, var(--amber), #fbbf24); }
.bar.bad > i { background: linear-gradient(90deg, var(--red), #f87171); }

/* ---------------- 表格 ---------------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar input[type=text], .toolbar input[type=search], .toolbar select {
  padding: 7px 10px; background: var(--bg-3); color: var(--txt);
  border: 1px solid var(--line-2); border-radius: 7px; outline: none; font-size: 12.5px;
}
.toolbar input:focus, .toolbar select:focus { border-color: var(--acc); }
.spacer { flex: 1; }

.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--bg-2); }
table { width: 100%; border-collapse: collapse; font-size: 12.5px; white-space: nowrap; }
thead th {
  position: sticky; top: 0; z-index: 2; background: #131b2b; color: var(--txt-2);
  text-align: left; font-weight: 500; padding: 10px 12px; border-bottom: 1px solid var(--line-2);
  cursor: pointer; user-select: none;
}
thead th:hover { color: var(--txt); }
thead th .arrow { opacity: .45; font-size: 10px; margin-left: 3px; }
tbody td { padding: 9px 12px; border-bottom: 1px solid #16203180; }
tbody tr:hover { background: #141d2e; }
tbody tr:last-child td { border-bottom: none; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 11.5px; }
.muted { color: var(--txt-3); }
.ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; }

.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; padding: 12px 4px 0; font-size: 12px; color: var(--txt-2); }
.pager .btn { padding: 4px 10px; }

.empty { padding: 40px; text-align: center; color: var(--txt-3); }

/* ---------------- 抽屉 ---------------- */
.drawer-mask { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; z-index: 50; }
.drawer-mask.show { display: block; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 460px; max-width: 92vw;
  background: var(--bg-2); border-left: 1px solid var(--line-2); z-index: 51;
  transform: translateX(100%); transition: transform .22s ease; display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.drawer-head h3 { font-size: 14px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px; }
.kv { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed #1c2740; gap: 16px; }
.kv .k { color: var(--txt-3); flex-shrink: 0; }
.kv .v { text-align: right; word-break: break-all; }

/* ---------------- 提示 ---------------- */
.toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #1b2537; border: 1px solid var(--line-2); color: var(--txt);
  padding: 10px 18px; border-radius: 9px; font-size: 13px; opacity: 0; z-index: 99;
  transition: .2s; pointer-events: none; box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.bad { border-color: rgba(239,68,68,.5); }

.hidden { display: none !important; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 4px; font-size: 11px; background: var(--bg-3); color: var(--txt-2); }

/* ---------------- 可钻取卡片 ---------------- */
a.card.drill {
  position: relative; display: block; color: inherit; text-decoration: none;
  transition: border-color .15s, background .15s, transform .12s;
}
a.card.drill:hover {
  border-color: var(--acc);
  background: linear-gradient(180deg, #141d2e 0%, var(--bg-2) 100%);
  transform: translateY(-1px);
}
a.card.drill:hover .drill-arrow { opacity: 1; transform: translateX(0); }
.drill-arrow {
  position: absolute; top: 12px; right: 14px; font-size: 16px; line-height: 1;
  color: var(--acc); opacity: 0; transform: translateX(-4px); transition: .15s;
}
.drill-hint { font-size: 11px; color: var(--txt-3); margin-top: 8px; }
a.card.drill:hover .drill-hint { color: var(--acc); }

/* 表格行可点 */
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: #17203380; }
tbody tr.clickable td:first-child { position: relative; }

/* 行内链接 */
.linkish { color: var(--acc); cursor: pointer; }
.linkish:hover { text-decoration: underline; }

/* ---------------- 响应式 ---------------- */
.nav-toggle { display: none; }
.nav-mask { display: none; }

@media (max-width: 960px) {
  .nav-toggle { display: inline-flex; }
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .right { gap: 8px; }
  .content { padding: 14px 14px 32px; }

  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 60; width: 236px;
    transform: translateX(-100%); transition: transform .2s ease;
    box-shadow: 0 0 30px rgba(0,0,0,.35);
  }
  .app.nav-open .sidebar { transform: translateX(0); }
  .app.nav-open .nav-mask {
    display: block; position: fixed; inset: 0; z-index: 55; background: rgba(0,0,0,.45);
  }

  .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .g3, .g2 { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .g4, .g3, .g2 { grid-template-columns: 1fr; }
  .topbar .crumb { font-size: 13px; }
  #syncBtn, #brandBtn, #userBox { display: none !important; }
  .kpi-val { font-size: 20px; }
  .drawer { width: 100%; max-width: 100%; }
  .toolbar { flex-wrap: wrap; gap: 8px; }
}