:root {
  --bg: #080b16;
  --bg-2: #0c1122;
  --panel: rgba(255, 255, 255, 0.038);
  --panel-2: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.15);
  --text: #e9edf8;
  --text-2: #aab4cc;
  --muted: #7a869e;
  --accent: #4f8cff;
  --accent-2: #8b5cf6;
  --ok: #2ecc8f;
  --warn: #f0b429;
  --err: #f2545b;
  --info: #38bdf8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --sans: "PingFang SC", "Microsoft YaHei", "HarmonyOS Sans SC", -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(900px 600px at 12% -8%, rgba(79, 140, 255, 0.16), transparent 60%),
    radial-gradient(800px 600px at 92% 8%, rgba(139, 92, 246, 0.14), transparent 62%),
    radial-gradient(700px 700px at 60% 110%, rgba(46, 204, 143, 0.08), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--accent); text-decoration: none; }

button { font-family: inherit; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.14); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.24); }

/* ============================ 登录页 ============================ */
.login-wrap {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 392px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 38px 34px 32px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: rise 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.login-logo {
  width: 56px; height: 56px;
  border-radius: 16px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 26px rgba(79, 140, 255, 0.35);
  margin: 0 auto 18px;
}
.login-logo svg { width: 30px; height: 30px; }

.login-title { text-align: center; font-size: 21px; font-weight: 700; margin: 0 0 6px; letter-spacing: 0.4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 12.5px; margin: 0 0 26px; }

.field { margin-bottom: 15px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 7px;
  font-weight: 500;
}
.input {
  width: 100%;
  padding: 11px 13px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  font-family: inherit;
}
.input:focus {
  border-color: rgba(79, 140, 255, 0.65);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.15);
  background: rgba(0, 0, 0, 0.4);
}
.input::placeholder { color: #5a6478; }
textarea.input { resize: vertical; min-height: 74px; font-family: var(--mono); font-size: 12.5px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.16s;
  white-space: nowrap;
}
.btn:hover { background: rgba(255, 255, 255, 0.1); border-color: var(--border-2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
  font-weight: 600;
  box-shadow: 0 8px 22px rgba(79, 140, 255, 0.3);
}
.btn-primary:hover { filter: brightness(1.08); background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; }
.btn-ghost { background: transparent; }
.btn-danger:hover { background: rgba(242, 84, 91, 0.16); border-color: rgba(242, 84, 91, 0.5); color: #ff9aa0; }

.login-err {
  background: rgba(242, 84, 91, 0.12);
  border: 1px solid rgba(242, 84, 91, 0.35);
  color: #ff9aa0;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  margin-bottom: 14px;
  display: none;
}
.login-err.show { display: block; animation: shake 0.32s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.login-foot {
  text-align: center;
  color: #55607a;
  font-size: 11.5px;
  margin-top: 22px;
  line-height: 1.7;
}

/* ============================ 控制台布局 ============================ */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex: 0 0 232px;
  border-right: 1px solid var(--border);
  background: rgba(8, 11, 22, 0.7);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand { display: flex; align-items: center; gap: 11px; padding: 0 6px 20px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 36px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(79, 140, 255, 0.32);
}
.brand-logo svg { width: 20px; height: 20px; }
.brand-name { font-size: 14.5px; font-weight: 700; letter-spacing: 0.3px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-sub { font-size: 10.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  cursor: pointer;
  transition: all 0.15s;
  border: 1px solid transparent;
  user-select: none;
}
.nav-item svg { width: 17px; height: 17px; flex: 0 0 17px; opacity: 0.85; }
.nav-item:hover { background: var(--panel); color: var(--text); }
.nav-item.active {
  background: linear-gradient(90deg, rgba(79, 140, 255, 0.18), rgba(139, 92, 246, 0.09));
  color: #fff;
  border-color: rgba(79, 140, 255, 0.28);
}
.nav-item.active svg { opacity: 1; }

.sidebar-foot { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--panel); margin-bottom: 9px;
}
.avatar {
  width: 30px; height: 30px; border-radius: 9px; flex: 0 0 30px;
  background: linear-gradient(135deg, #2ecc8f, var(--accent));
  display: grid; place-items: center;
  font-weight: 700; font-size: 13px; color: #fff;
}
.user-name { font-size: 13px; font-weight: 600; }
.user-role { font-size: 10.5px; color: var(--muted); }

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

.topbar {
  height: 64px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  background: rgba(8, 11, 22, 0.55);
  backdrop-filter: blur(14px);
  position: sticky; top: 0; z-index: 20;
}
.page-title { font-size: 16.5px; font-weight: 700; }
.page-desc { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px 26px 60px; flex: 1; }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: blur(10px);
}
.panel + .panel { margin-top: 18px; }
.panel-title {
  font-size: 14px; font-weight: 700; margin: 0 0 3px;
  display: flex; align-items: center; gap: 8px;
}
.panel-title .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.panel-desc { font-size: 12px; color: var(--muted); margin: 0 0 16px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.row > .field { margin-bottom: 0; flex: 1; min-width: 170px; }

/* 统计卡 */
.stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  position: relative;
  overflow: hidden;
}
.stat-label { font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.5px; font-variant-numeric: tabular-nums; }
.stat-unit { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 3px; }

/* 评分环 */
.score-hero { display: flex; align-items: center; gap: 30px; flex-wrap: wrap; }
.ring-wrap { position: relative; width: 152px; height: 152px; flex: 0 0 152px; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255, 255, 255, 0.08); stroke-width: 11; }
.ring-fg {
  fill: none; stroke-width: 11; stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1);
}
.ring-center {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center;
}
.ring-num { font-size: 38px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-cap { font-size: 11px; color: var(--muted); margin-top: 3px; }

.layer-bars { flex: 1; min-width: 260px; display: grid; gap: 11px; }
.layer { display: grid; grid-template-columns: 74px 1fr 42px; align-items: center; gap: 12px; }
.layer-name { font-size: 12.5px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; }
.layer-track { height: 8px; background: rgba(255, 255, 255, 0.07); border-radius: 5px; overflow: hidden; }
.layer-fill { height: 100%; border-radius: 5px; width: 0; transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1); }
.layer-val { font-size: 13px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 11.5px; font-weight: 600; line-height: 1.5;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-err { background: rgba(242, 84, 91, 0.14); color: #ff9aa0; border-color: rgba(242, 84, 91, 0.32); }
.badge-warn { background: rgba(240, 180, 41, 0.14); color: #ffcd69; border-color: rgba(240, 180, 41, 0.32); }
.badge-info { background: rgba(56, 189, 248, 0.13); color: #7dd3fc; border-color: rgba(56, 189, 248, 0.3); }
.badge-ok { background: rgba(46, 204, 143, 0.14); color: #6ee7b7; border-color: rgba(46, 204, 143, 0.32); }
.badge-mute { background: rgba(255, 255, 255, 0.07); color: var(--text-2); border-color: var(--border); }

/* 表格 */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
table.tbl th {
  text-align: left; padding: 10px 12px; color: var(--muted);
  font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.tbl td { padding: 11px 12px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }
table.tbl tbody tr:hover { background: rgba(255, 255, 255, 0.03); }
td.mono, .mono { font-family: var(--mono); font-size: 12px; }
td.ellip { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 终端输出 */
.terminal {
  background: #05070f;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.75;
  color: #c8d3e8;
  max-height: 380px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-all;
}
.terminal .l-ok { color: #6ee7b7; }
.terminal .l-err { color: #ff9aa0; }
.terminal .l-cmd { color: #7dd3fc; }
.terminal .l-warn { color: #ffcd69; }

/* 进度条 */
.progress { height: 3px; background: rgba(255, 255, 255, 0.08); border-radius: 3px; overflow: hidden; margin-bottom: 14px; }
.progress-bar {
  height: 100%; width: 30%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 3px;
  animation: slide 1.15s ease-in-out infinite;
}
@keyframes slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(340%); }
}

/* 空态 */
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty svg { width: 42px; height: 42px; opacity: 0.35; margin-bottom: 12px; }
.empty-title { font-size: 14px; color: var(--text-2); margin-bottom: 5px; font-weight: 600; }
.empty-desc { font-size: 12.5px; }

/* 代码预览 */
.codebox {
  background: #05070f; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #c8d3e8; max-height: 360px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}
.file-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.file-tab {
  padding: 6px 13px; border-radius: 8px; font-size: 12.5px; cursor: pointer;
  border: 1px solid var(--border); background: var(--panel); color: var(--text-2);
  transition: all 0.15s; font-family: var(--mono);
}
.file-tab:hover { color: var(--text); }
.file-tab.active { background: rgba(79, 140, 255, 0.16); color: #fff; border-color: rgba(79, 140, 255, 0.4); }

/* 分段控件 */
.seg { display: inline-flex; background: var(--panel); border: 1px solid var(--border); border-radius: 9px; padding: 3px; gap: 2px; }
.seg button {
  padding: 5px 13px; border: none; background: transparent; color: var(--text-2);
  font-size: 12.5px; border-radius: 7px; cursor: pointer; transition: all 0.15s;
}
.seg button.active { background: rgba(255, 255, 255, 0.1); color: #fff; font-weight: 600; }

/* 模态 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(4, 6, 12, 0.72); backdrop-filter: blur(5px);
  display: none; place-items: center; z-index: 100; padding: 24px;
}
.modal-mask.show { display: grid; }
.modal {
  width: 100%; max-width: 520px; max-height: 86vh; overflow: auto;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: 18px; padding: 24px; box-shadow: var(--shadow);
  animation: rise 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close {
  background: transparent; border: none; color: var(--muted); cursor: pointer;
  font-size: 21px; line-height: 1; padding: 2px 7px; border-radius: 7px;
}
.modal-close:hover { background: var(--panel-2); color: var(--text); }

/* 提示条 */
.toast-host { position: fixed; top: 18px; right: 18px; z-index: 200; display: flex; flex-direction: column; gap: 9px; }
.toast {
  min-width: 240px; max-width: 380px; padding: 12px 15px;
  background: rgba(18, 24, 42, 0.96); border: 1px solid var(--border-2);
  border-left: 3px solid var(--accent);
  border-radius: 11px; box-shadow: var(--shadow); font-size: 13px;
  animation: slideIn 0.28s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.ok { border-left-color: var(--ok); }
.toast.err { border-left-color: var(--err); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { opacity: 0; transform: translateX(24px); } to { opacity: 1; transform: none; } }

.hidden { display: none !important; }
.view { animation: fade 0.28s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

.hint { font-size: 11.5px; color: var(--muted); margin-top: 6px; line-height: 1.6; }
.spin {
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff; border-radius: 50%; animation: rot 0.7s linear infinite;
}
@keyframes rot { to { transform: rotate(360deg); } }

/* AI 开关 */
.ai-toggle {
  position: relative;
  display: inline-flex; align-items: center; gap: 9px; cursor: pointer;
  padding: 9px 13px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--panel); user-select: none; transition: all 0.18s ease;
}
.ai-toggle:hover { border-color: var(--border-2); background: var(--panel-2); }
.ai-toggle input { display: none; }
.ai-toggle > span { display: flex; flex-direction: column; line-height: 1.35; }
.ai-toggle > span > b { font-size: 13px; font-weight: 600; color: var(--text-2); }
.ai-toggle > span > i { font-style: normal; font-size: 11px; color: var(--muted); }
/* 轨道 */
.ai-toggle::before {
  content: ""; width: 34px; height: 19px; border-radius: 12px; flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.13); transition: background 0.2s ease;
}
/* 滑块 */
.ai-toggle::after {
  content: ""; width: 13px; height: 13px; border-radius: 50%; background: #fff;
  position: absolute; left: 16px; top: 50%; pointer-events: none;
  transform: translate(0, -50%); transition: transform 0.2s ease;
}
.ai-toggle:has(input:checked) { border-color: rgba(79, 140, 255, 0.5); background: rgba(79, 140, 255, 0.1); }
.ai-toggle:has(input:checked)::before { background: var(--accent); }
.ai-toggle:has(input:checked)::after { transform: translate(18px, -50%); }
.ai-toggle:has(input:checked) > span > b { color: var(--text); }
.ai-toggle:has(input:checked) > span > i { color: var(--accent); }
.ai-toggle.off { opacity: 0.45; cursor: not-allowed; }

.hint code {
  font-family: var(--mono); font-size: 11.5px; padding: 1px 5px;
  background: rgba(255, 255, 255, 0.07); border-radius: 4px; color: var(--text-2);
}

.mobile-top { display: none; }

@media (max-width: 860px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 60; transform: translateX(-100%);
    transition: transform 0.25s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .content { padding: 18px 15px 60px; }
  .topbar { padding: 0 15px; }
  .mobile-top { display: inline-flex; }
  .score-hero { gap: 20px; }
}
