:root {
  --bg: #0a0e15;
  --bg-soft: #0f1420;
  --panel: #131a28;
  --panel-2: #18212f;
  --line: #232e42;
  --line-soft: #1b2434;
  --text: #e8eef9;
  --muted: #8a97ad;
  --muted-2: #647089;
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, .14);
  --violet: #a78bfa;
  --green: #34d399;
  --green-soft: rgba(52, 211, 153, .13);
  --amber: #fbbf24;
  --amber-soft: rgba(251, 191, 36, .13);
  --red: #f87171;
  --red-soft: rgba(248, 113, 113, .13);
  --radius: 14px;
  --shadow: 0 18px 48px rgba(0, 0, 0, .38);
}

* { box-sizing: border-box; }

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

body {
  background-image:
    radial-gradient(900px 420px at 12% -8%, rgba(91, 140, 255, .12), transparent 65%),
    radial-gradient(760px 380px at 96% 0%, rgba(167, 139, 250, .09), transparent 60%);
  background-attachment: fixed;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: "JetBrains Mono", ui-monospace, Consolas, monospace; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

/* ---------------------------------------------------------------- 登录 */
.login {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 380px;
  max-width: 100%;
  background: linear-gradient(180deg, rgba(24, 33, 47, .95), rgba(16, 22, 33, .96));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 30px 28px 22px;
  box-shadow: var(--shadow);
}
.login-card form { display: grid; gap: 16px; margin-top: 26px; }
.login-card label { display: grid; gap: 8px; font-size: 12.5px; color: var(--muted); }
.login-card input {
  height: 42px;
  padding: 0 14px;
  background: #0d1320;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.login-card input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.login-error { color: var(--red); font-size: 12.5px; min-height: 18px; margin: 0; }
.login-foot { margin: 18px 0 0; color: var(--muted-2); font-size: 12px; line-height: 1.6; }

.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.brand p { margin: 2px 0 0; font-size: 12px; color: var(--muted-2); }
.brand-mark {
  width: 38px; height: 38px;
  border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #5b8cff, #a78bfa);
  font-weight: 700; font-size: 19px; color: #fff;
  box-shadow: 0 8px 20px rgba(91, 140, 255, .32);
}
.brand.small .brand-mark { width: 32px; height: 32px; border-radius: 9px; font-size: 16px; }
.brand.small h1 { font-size: 14.5px; }

/* ---------------------------------------------------------------- 布局 */
.app { display: flex; min-height: 100%; }

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  border-right: 1px solid var(--line-soft);
  background: rgba(13, 18, 28, .82);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 20px 12px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar .brand { padding: 0 8px 18px; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; flex: 1; }
.nav-title {
  font-size: 11px; color: var(--muted-2);
  padding: 16px 12px 6px;
  letter-spacing: 1px;
}
.nav a {
  display: flex; align-items: center; gap: 10px;
  height: 38px; padding: 0 12px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13.5px;
  transition: background .15s, color .15s;
}
.nav a i {
  font-style: normal; width: 16px; text-align: center;
  font-size: 13px; opacity: .85;
}
.nav a:hover { background: rgba(255, 255, 255, .04); color: var(--text); }
.nav a.active {
  background: var(--accent-soft);
  color: #cfe0ff;
  box-shadow: inset 0 0 0 1px rgba(91, 140, 255, .22);
}
.sidebar-foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 12px 4px;
  font-size: 11.5px; color: var(--muted-2);
  border-top: 1px solid var(--line-soft);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.dot.live { background: var(--green); box-shadow: 0 0 0 3px rgba(52, 211, 153, .16); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 72px;
  padding: 0 26px;
  display: flex; align-items: center; justify-content: space-between;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(10, 14, 21, .6);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar p { margin: 3px 0 0; font-size: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.user-chip { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel-2); border: 1px solid var(--line);
  font-size: 12px; color: #cfe0ff;
}

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 11.5px; color: var(--muted);
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
}

.view { padding: 22px 26px 56px; display: flex; flex-direction: column; gap: 18px; }

/* ---------------------------------------------------------------- 卡片 */
.card {
  background: linear-gradient(180deg, rgba(20, 27, 40, .92), rgba(16, 22, 33, .92));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 18px;
}
.card.pad-0 { padding: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h3 { margin: 0; font-size: 14px; font-weight: 600; }
.card-head p { margin: 3px 0 0; font-size: 12px; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 14px; }
.stat {
  background: linear-gradient(180deg, rgba(24, 33, 47, .9), rgba(16, 22, 33, .9));
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.stat::after {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), transparent);
  opacity: .55;
}
.stat .k { font-size: 12px; color: var(--muted); }
.stat .v { font-size: 24px; font-weight: 650; margin-top: 8px; letter-spacing: .4px; }
.stat .s { font-size: 11.5px; color: var(--muted-2); margin-top: 6px; }
.stat.green::after { background: linear-gradient(90deg, var(--green), transparent); }
.stat.amber::after { background: linear-gradient(90deg, var(--amber), transparent); }
.stat.red::after { background: linear-gradient(90deg, var(--red), transparent); }

/* ---------------------------------------------------------------- 表格 */
.table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--line-soft); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  font-weight: 500;
  color: var(--muted-2);
  font-size: 11.5px;
  letter-spacing: .4px;
  padding: 11px 14px;
  background: rgba(255, 255, 255, .022);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
}
tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(35, 46, 66, .55);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(255, 255, 255, .022); }
td.actions { white-space: nowrap; }
.empty { padding: 42px 16px; text-align: center; color: var(--muted-2); font-size: 13px; }

.cell-main { font-weight: 550; }
.cell-sub { font-size: 11.5px; color: var(--muted-2); margin-top: 3px; }

/* ---------------------------------------------------------------- 控件 */
.btn {
  height: 34px;
  padding: 0 14px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, border-color .15s, opacity .15s;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  white-space: nowrap;
}
.btn:hover { background: #1e2839; border-color: #2c3a52; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary {
  background: linear-gradient(135deg, #5b8cff, #6f7bff);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 16px rgba(91, 140, 255, .25);
}
.btn.primary:hover { background: linear-gradient(135deg, #6b98ff, #7d88ff); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .04); }
.btn.danger { color: var(--red); border-color: rgba(248, 113, 113, .3); background: var(--red-soft); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn.block { width: 100%; }
.btn.link { background: none; border: none; color: var(--accent); padding: 0 4px; height: auto; }

input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: #0d1320;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
textarea { height: auto; min-height: 110px; padding: 10px 12px; line-height: 1.65; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input::placeholder, textarea::placeholder { color: var(--muted-2); }
select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 16px) 15px, calc(100% - 11px) 15px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.toolbar .search { width: 220px; }
.tabs { display: inline-flex; padding: 3px; background: var(--panel); border: 1px solid var(--line-soft); border-radius: 10px; gap: 2px; }
.tabs button {
  height: 28px; padding: 0 12px;
  border: none; background: transparent; color: var(--muted);
  border-radius: 7px; cursor: pointer; font-size: 12.5px; font-family: inherit;
}
.tabs button.active { background: var(--accent-soft); color: #cfe0ff; }

/* 开关 */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 13px; }
.switch input { display: none; }
.switch .track {
  width: 38px; height: 21px; border-radius: 20px; background: #2a3549;
  position: relative; transition: background .18s; flex: 0 0 38px;
}
.switch .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: #93a0b8;
  transition: transform .18s, background .18s;
}
.switch input:checked + .track { background: rgba(91, 140, 255, .45); }
.switch input:checked + .track::after { transform: translateX(17px); background: #fff; }

/* 徽标 */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid var(--line-soft);
  white-space: nowrap;
}
.badge.green { background: var(--green-soft); color: #6ee7b7; border-color: rgba(52, 211, 153, .25); }
.badge.amber { background: var(--amber-soft); color: #fcd34d; border-color: rgba(251, 191, 36, .25); }
.badge.red { background: var(--red-soft); color: #fca5a5; border-color: rgba(248, 113, 113, .25); }
.badge.blue { background: var(--accent-soft); color: #a9c4ff; border-color: rgba(91, 140, 255, .25); }
.badge.violet { background: rgba(167, 139, 250, .14); color: #c4b5fd; border-color: rgba(167, 139, 250, .25); }

/* ---------------------------------------------------------------- 模态框 */
.modal-mask {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(5, 8, 13, .68);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 24px;
  animation: fade .12s ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 520px; max-width: 100%;
  max-height: 86vh;
  display: flex; flex-direction: column;
  background: #121a28;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  animation: pop .16s ease-out;
}
.modal.wide { width: 760px; }
@keyframes pop { from { transform: translateY(8px) scale(.99); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 14px 20px; border-top: 1px solid var(--line-soft); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; gap: 14px; }
.form-grid .cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: grid; gap: 7px; }
.field > span { font-size: 12.5px; color: var(--muted); }
.field .help { font-size: 11.5px; color: var(--muted-2); line-height: 1.55; }
.icon-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1; padding: 4px; }
.icon-btn:hover { color: var(--text); }

/* ---------------------------------------------------------------- 提示 */
.toasts { position: fixed; right: 22px; bottom: 22px; display: flex; flex-direction: column; gap: 10px; z-index: 120; }
.toast {
  min-width: 220px; max-width: 380px;
  padding: 12px 16px;
  border-radius: 10px;
  background: #1a2333;
  border: 1px solid var(--line);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
  font-size: 13px;
  animation: slidein .18s ease-out;
}
.toast.ok { border-color: rgba(52, 211, 153, .35); }
.toast.err { border-color: rgba(248, 113, 113, .4); }
@keyframes slidein { from { transform: translateX(16px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------------------------------------------------------- 概览 */
.grid-2 { display: grid; grid-template-columns: 1.5fr 1fr; gap: 18px; }
@media (max-width: 1080px) { .grid-2 { grid-template-columns: 1fr; } }

.log-list { display: flex; flex-direction: column; }
.log-item {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 2px;
  border-bottom: 1px dashed rgba(35, 46, 66, .6);
  font-size: 12.5px;
}
.log-item:last-child { border-bottom: none; }
.log-item .t { color: var(--muted-2); font-size: 11px; white-space: nowrap; padding-top: 2px; font-family: ui-monospace, Consolas, monospace; }
.log-item .m { color: var(--muted); line-height: 1.55; }
.lvl { width: 6px; height: 6px; border-radius: 50%; margin-top: 7px; flex: 0 0 6px; background: var(--muted-2); }
.lvl.INFO { background: var(--accent); }
.lvl.WARN { background: var(--amber); }
.lvl.ERROR { background: var(--red); }

.bar { height: 7px; border-radius: 5px; background: #1d2637; overflow: hidden; display: flex; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #34d399, #4ade80); }
.bar i.skip { background: linear-gradient(90deg, #fbbf24, #f59e0b); }

.kv { display: grid; grid-template-columns: 116px 1fr; gap: 10px 14px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--text); word-break: break-all; }

.code {
  background: #0b111c;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: "JetBrains Mono", ui-monospace, Consolas, monospace;
  font-size: 12px;
  color: #b6c8e6;
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.7;
  margin: 0;
}

.policy-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px; }
.stack { display: grid; gap: 12px; }

.provider-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, .018);
  display: grid;
  gap: 12px;
}
.provider-card.off { opacity: .62; }

/* 模型接入向导 */
.wizard-intro { font-size: 12.5px; color: var(--muted); line-height: 1.8; margin-bottom: 14px; }
.wizard-list { display: grid; gap: 12px; }
.wizard-item {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, .018);
  display: grid;
  gap: 8px;
}
.wizard-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wizard-steps { margin: 2px 0 0; padding-left: 18px; font-size: 12.5px; color: var(--muted); line-height: 1.85; }
.wizard-steps li { margin: 0; }
.wizard-note {
  margin-top: 16px;
  border: 1px dashed var(--line-soft);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.85;
}
.wizard-note strong { color: var(--text); }
.wizard-note ol { margin: 6px 0 0; padding-left: 18px; }

.kb-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 16px;
  background: rgba(255, 255, 255, .018);
  display: flex; flex-direction: column; gap: 10px;
  cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.kb-card:hover { border-color: rgba(91, 140, 255, .4); transform: translateY(-1px); }
.kb-card h4 { margin: 0; font-size: 14px; }
.kb-card p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.6; }

.back-link { color: var(--muted); text-decoration: none; font-size: 12.5px; }
.back-link:hover { color: var(--text); }

.divider { height: 1px; background: var(--line-soft); margin: 4px 0; }

@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .view { padding: 16px; }
  .topbar { padding: 0 16px; }
}
