:root {
  --primary: #6e8cff;
  --primary-dark: #5270e8;
  --mint: #3bb08f;
  --yellow: #ffcb57;
  --purple: #b9a8f0;
  --ink: #2f2b3a;
  --muted: #8a8698;
  --line: #edf0f6;
  --bg: #f5f7fb;
  --card: #ffffff;
  --danger: #e25656;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(46, 54, 92, .06);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 420px at 85% 5%, rgba(110,140,255,.16), transparent 60%),
    radial-gradient(700px 500px at 5% 90%, rgba(59,176,143,.14), transparent 60%),
    #f7f8fc;
}
.login-card {
  width: 420px;
  max-width: 100%;
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 20px 60px rgba(40, 50, 90, .12);
  padding: 38px 38px 32px;
}
.login-logo {
  width: 54px; height: 54px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), #9db0ff);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 800; font-size: 24px;
  box-shadow: 0 8px 20px rgba(110,140,255,.32);
}
.login-title { font-size: 24px; font-weight: 800; margin: 20px 0 6px; letter-spacing: -.5px; }
.login-sub { color: var(--muted); margin: 0 0 28px; }
.login-card .field { margin-bottom: 18px; }
.login-card .field label { display: block; margin-bottom: 8px; font-weight: 600; }
.login-card .btn-primary { width: 100%; height: 44px; margin-top: 8px; }
.login-hint { margin-top: 20px; text-align: center; color: var(--muted); font-size: 12px; line-height: 1.7; }

/* ---------- 布局 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 232px; flex: none; background: #fff; border-right: 1px solid var(--line);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 24px 20px 20px; }
.brand-icon {
  width: 38px; height: 38px; border-radius: 12px; flex: none;
  background: linear-gradient(135deg, var(--primary), #a6b7ff);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.brand-name { font-weight: 800; font-size: 16px; line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.nav { flex: 1; overflow-y: auto; padding: 8px 12px 20px; }
.nav-group { margin: 14px 10px 6px; font-size: 11px; color: #b0adba; letter-spacing: 1px; font-weight: 700; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 11px 12px; border-radius: 10px;
  color: #656174; cursor: pointer; margin-bottom: 2px; font-weight: 600; transition: .15s;
}
.nav-item:hover { background: #f5f6fc; color: var(--ink); }
.nav-item.active { background: #eef1ff; color: var(--primary-dark); }
.nav-item svg { width: 18px; height: 18px; flex: none; }
.nav-item .badge { margin-left: auto; font-size: 11px; background: var(--danger); color: #fff; border-radius: 9px; padding: 1px 6px; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }
.main { flex: 1; min-width: 0; }
.topbar {
  height: 68px; background: rgba(255,255,255,.9); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); display: flex; align-items: center;
  justify-content: space-between; padding: 0 30px; position: sticky; top: 0; z-index: 10;
}
.crumb { font-size: 17px; font-weight: 800; }
.crumb small { font-size: 12px; color: var(--muted); font-weight: 500; margin-left: 10px; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 10px; background: #eef1ff; color: var(--primary-dark); display: flex; align-items: center; justify-content: center; font-weight: 800; }
.content { padding: 26px 30px 50px; max-width: 1500px; }

/* ---------- 通用组件 ---------- */
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 8px 14px; border-radius: 9px; font-weight: 600; transition: .15s;
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
}
.btn:hover { border-color: #d8ddf0; background: #fafbff; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px rgba(110,140,255,.22); }
.btn-primary:hover { background: var(--primary-dark); border-color: var(--primary-dark); }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fff2f2; border-color: #f5c9c9; }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: 7px; }
.btn-ghost { border: 0; background: transparent; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.card-title { font-size: 15px; font-weight: 800; }
.card-sub { color: var(--muted); font-size: 12px; font-weight: 400; margin-left: 8px; }

.grid { display: grid; gap: 18px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.mb18 { margin-bottom: 18px; }

.stat { position: relative; overflow: hidden; }
.stat-label { color: var(--muted); font-size: 13px; }
.stat-value { font-size: 32px; font-weight: 800; letter-spacing: -1px; margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
.stat-foot { font-size: 12px; color: var(--muted); }
.stat-icon { position: absolute; right: 18px; top: 18px; width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 18px; }
.stat-icon.blue { background: #eef1ff; color: var(--primary); }
.stat-icon.green { background: #e7f7f1; color: var(--mint); }
.stat-icon.yellow { background: #fff6de; color: #d99b18; }
.stat-icon.purple { background: #f2eefe; color: #8e76dd; }
.trend-up { color: var(--mint); font-weight: 700; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; }
.input, .select, .textarea {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 9px; padding: 9px 12px; outline: none; min-height: 38px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(110,140,255,.12); }
.input-search { width: 240px; }
.select { width: auto; min-width: 120px; }
.textarea { resize: vertical; min-height: 110px; line-height: 1.6; font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 7px; font-size: 13px; }
.field .help { color: var(--muted); font-size: 12px; margin-top: 5px; line-height: 1.5; }
.checkline { display: flex; align-items: center; gap: 8px; font-weight: 500; }
.checkline input { width: 16px; height: 16px; accent-color: var(--primary); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; color: var(--muted); font-size: 12px; font-weight: 700; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 13px 10px; border-bottom: 1px solid #f3f5fa; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbff; }
.cell-strong { font-weight: 700; }
.cell-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
.cell-actions { white-space: nowrap; }
.cell-actions .btn { margin-right: 6px; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }
.empty b { display: block; font-size: 16px; color: var(--ink); margin-bottom: 6px; }

.tag { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 20px; font-size: 12px; font-weight: 700; }
.tag.green { background: #e7f7f1; color: #1f8d6e; }
.tag.red { background: #ffeded; color: #d34b4b; }
.tag.blue { background: #eef1ff; color: var(--primary-dark); }
.tag.yellow { background: #fff6de; color: #b98518; }
.tag.gray { background: #f1f2f6; color: #8b8999; }
.tag.purple { background: #f2eefe; color: #8e76dd; }

.pager { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding-top: 16px; color: var(--muted); font-size: 13px; }
.pager button { min-width: 32px; }

.bar-chart { display: flex; align-items: flex-end; gap: 12px; height: 160px; padding: 10px 4px 0; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 34px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #93a8ff, var(--primary)); min-height: 4px; transition: height .3s; }
.bar-label { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar-value { font-size: 11px; font-weight: 700; color: var(--primary-dark); }

.donut-wrap { display: flex; align-items: center; gap: 26px; }
.donut { width: 148px; height: 148px; border-radius: 50%; flex: none; position: relative; }
.donut::after { content: ''; position: absolute; inset: 27px; background: #fff; border-radius: 50%; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; z-index: 1; }
.donut-center b { font-size: 22px; }
.donut-center span { font-size: 11px; color: var(--muted); }
.legend { flex: 1; min-width: 0; }
.legend-row { display: flex; align-items: center; gap: 9px; padding: 6px 0; font-size: 13px; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.legend-row .num { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.config-item { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; }
.config-item .title { font-weight: 700; }
.config-item .desc { color: var(--muted); font-size: 12px; margin-top: 4px; }
.provider-card { border: 1px solid var(--line); border-radius: 13px; padding: 16px; margin-bottom: 12px; }
.provider-card.active { border-color: #cdd7ff; background: #fbfcff; }
.provider-top { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.provider-top .name { font-weight: 800; font-size: 15px; }
.provider-meta { display: flex; flex-wrap: wrap; gap: 8px 18px; color: var(--muted); font-size: 12px; }
.provider-meta code { color: var(--ink); background: #f5f6fa; padding: 2px 6px; border-radius: 5px; }
.provider-actions { margin-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; }
.prompt-text { white-space: pre-wrap; word-break: break-word; background: #f7f8fc; border-radius: 10px; padding: 12px; max-height: 210px; overflow: auto; font-size: 12px; line-height: 1.65; font-family: ui-monospace, Consolas, monospace; }
.record-thumb { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #f7f8fc; cursor: zoom-in; display: block; }
.detail-image { display: block; max-width: 100%; max-height: 300px; border-radius: 12px; border: 1px solid var(--line); background: #f7f8fc; margin-bottom: 14px; cursor: zoom-in; }
.radar-svg { width: 100%; max-width: 280px; display: block; margin: 4px auto 8px; }

/* ---------- 弹窗 / 提示 ---------- */
.modal-mask { position: fixed; inset: 0; background: rgba(25,28,45,.42); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; }
.modal { background: #fff; border-radius: 16px; width: 620px; max-width: 100%; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 24px 70px rgba(20,25,50,.22); }
.modal.wide { width: 820px; }
.modal-head { padding: 20px 24px 14px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-body { padding: 20px 24px; overflow-y: auto; }
.modal-foot { padding: 14px 24px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.x-btn { border: 0; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; }
.toast-box { position: fixed; top: 22px; right: 24px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #fff; border-left: 4px solid var(--mint); box-shadow: 0 8px 30px rgba(30,40,70,.14); border-radius: 9px; padding: 12px 18px; min-width: 220px; font-weight: 600; animation: slidein .2s ease-out; }
.toast.error { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }
.loading { display: flex; align-items: center; justify-content: center; padding: 50px; color: var(--muted); }

@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .sidebar { width: 68px; }
  .brand-name, .brand-sub, .nav-item span, .nav-group, .sidebar-foot { display: none; }
  .nav-item { justify-content: center; }
  .content { padding: 18px; }
  .topbar { padding: 0 18px; }
  .grid-4 { grid-template-columns: 1fr; }
}
