:root {
  --bg: #07080b;
  --bg-soft: #0c0e13;
  --panel: #11131a;
  --panel-2: #161922;
  --line: #232733;
  --line-soft: #1a1d26;
  --text: #e9ebf2;
  --text-dim: #9aa1b2;
  --text-faint: #646b7d;
  --accent: #12e0a7;
  --accent-dim: rgba(18, 224, 167, 0.12);
  --blue: #5b8cff;
  --danger: #ff5f6d;
  --danger-dim: rgba(255, 95, 109, 0.12);
  --warn: #ffb648;
  --warn-dim: rgba(255, 182, 72, 0.12);
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

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

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(1100px 500px at 82% -12%, rgba(18, 224, 167, 0.07), transparent 60%),
    radial-gradient(900px 450px at 8% 110%, rgba(91, 140, 255, 0.05), transparent 60%);
  background-attachment: fixed;
}

a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #262a36; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ───────── 登录页 ───────── */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(180deg, rgba(22, 25, 34, 0.95), rgba(14, 16, 22, 0.95));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 34px 30px 28px;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.brand-row { display: flex; align-items: center; gap: 11px; margin-bottom: 22px; }
.logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(140deg, var(--accent), #0a9e77);
  display: grid; place-items: center;
  color: #04120d; font-weight: 800; font-size: 17px;
  box-shadow: 0 6px 20px -6px rgba(18, 224, 167, 0.6);
}
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: -0.2px; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); letter-spacing: 0.4px; text-transform: uppercase; }
.auth-title { font-size: 21px; font-weight: 650; letter-spacing: -0.4px; margin-bottom: 5px; }
.auth-desc { color: var(--text-dim); font-size: 13px; margin-bottom: 22px; }

/* ───────── 表单 ───────── */
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; color: var(--text-dim);
  margin-bottom: 6px; font-weight: 500; letter-spacing: 0.2px;
}
.field .hint { font-size: 11.5px; color: var(--text-faint); margin-top: 5px; line-height: 1.45; }
.input, .select, .textarea {
  width: 100%;
  background: #0a0c11;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: var(--text);
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
  font-size: 13.5px;
}
.input::placeholder, .textarea::placeholder { color: #4a5061; }
.input:focus, .select:focus, .textarea:focus {
  border-color: rgba(18, 224, 167, 0.55);
  box-shadow: 0 0 0 3px rgba(18, 224, 167, 0.08);
  background: #0b0e14;
}
.textarea { resize: vertical; min-height: 96px; font-family: var(--mono); font-size: 12.5px; line-height: 1.7; }
.select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa1b2' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px; }
.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ───────── 按钮 ───────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text);
  padding: 8px 14px; font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
  user-select: none;
}
.btn:hover { background: #1c202a; border-color: #2e3341; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(180deg, #17eeb2, #0fc392);
  border-color: transparent; color: #04140f; font-weight: 650;
  box-shadow: 0 6px 18px -8px rgba(18, 224, 167, 0.7);
}
.btn-primary:hover { background: linear-gradient(180deg, #2bf5bd, #13d29e); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: rgba(255, 255, 255, 0.05); color: var(--text); }
.btn-danger { color: var(--danger); border-color: rgba(255, 95, 109, 0.28); background: var(--danger-dim); }
.btn-danger:hover { background: rgba(255, 95, 109, 0.2); border-color: rgba(255, 95, 109, 0.45); }
.btn-sm { padding: 5px 9px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; }
.btn-icon { padding: 6px; width: 30px; height: 30px; }

/* ───────── 布局 ───────── */
.layout { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }

.sidebar {
  border-right: 1px solid var(--line-soft);
  background: rgba(10, 12, 16, 0.7);
  backdrop-filter: blur(12px);
  padding: 18px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 18px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-faint); padding: 12px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--text-dim); font-size: 13.5px; font-weight: 500;
  cursor: pointer; transition: all 0.14s;
  border: 1px solid transparent;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); border-color: rgba(18, 224, 167, 0.18); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.nav-item .badge-dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: var(--danger); }
.side-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line-soft); }
.user-chip { display: flex; align-items: center; gap: 9px; padding: 8px 8px; border-radius: 9px; }
.avatar {
  width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
  background: linear-gradient(140deg, #2a3140, #1a1f2b);
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent);
  border: 1px solid var(--line);
}
.user-meta { min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10.5px; color: var(--text-faint); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; border-bottom: 1px solid var(--line-soft);
  position: sticky; top: 0; z-index: 20;
  background: rgba(7, 8, 11, 0.82); backdrop-filter: blur(14px);
}
.page-title { font-size: 17px; font-weight: 640; letter-spacing: -0.3px; }
.page-sub { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.content { padding: 24px 28px 64px; max-width: 1440px; width: 100%; }

/* ───────── 卡片 ───────── */
.card {
  background: linear-gradient(180deg, rgba(20, 23, 31, 0.9), rgba(14, 16, 22, 0.9));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 15px 18px; border-bottom: 1px solid var(--line-soft);
}
.card-title { font-size: 13.5px; font-weight: 600; letter-spacing: -0.1px; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat {
  background: linear-gradient(180deg, rgba(20, 23, 31, 0.9), rgba(13, 15, 20, 0.9));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; position: relative; overflow: hidden;
}
.stat::after {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.09), transparent);
}
.stat-label { font-size: 11.5px; color: var(--text-faint); letter-spacing: 0.3px; display: flex; align-items: center; gap: 6px; }
.stat-value { font-size: 26px; font-weight: 680; letter-spacing: -1px; margin-top: 7px; font-variant-numeric: tabular-nums; }
.stat-value.sm { font-size: 21px; }
.stat-foot { font-size: 11.5px; color: var(--text-dim); margin-top: 5px; display: flex; align-items: center; gap: 6px; }
.stat-accent { color: var(--accent); }

.grid-2 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

/* ───────── 表格 ───────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  text-align: left; font-weight: 500; font-size: 11.5px; color: var(--text-faint);
  padding: 10px 14px; border-bottom: 1px solid var(--line-soft);
  letter-spacing: 0.4px; text-transform: uppercase; white-space: nowrap;
  background: rgba(255, 255, 255, 0.012);
}
td { padding: 12px 14px; border-bottom: 1px solid rgba(35, 39, 51, 0.55); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.12s; }
tbody tr:hover { background: rgba(255, 255, 255, 0.018); }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -0.2px; }
.dim { color: var(--text-dim); }
.faint { color: var(--text-faint); }
.nowrap { white-space: nowrap; }
.truncate { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── 徽章 ───────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 550; padding: 2.5px 8px;
  border-radius: 999px; border: 1px solid transparent; white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.badge-ok { color: #2ee6a8; background: rgba(46, 230, 168, 0.1); border-color: rgba(46, 230, 168, 0.2); }
.badge-err { color: #ff6b78; background: var(--danger-dim); border-color: rgba(255, 95, 109, 0.22); }
.badge-warn { color: #ffbd5c; background: var(--warn-dim); border-color: rgba(255, 182, 72, 0.22); }
.badge-dim { color: var(--text-faint); background: rgba(255, 255, 255, 0.04); border-color: var(--line); }
.badge-blue { color: #7ba2ff; background: rgba(91, 140, 255, 0.1); border-color: rgba(91, 140, 255, 0.22); }
.badge-plain::before { display: none; }

/* ───────── 厂家卡 ───────── */
.provider-card { margin-bottom: 14px; }
.provider-head {
  display: flex; align-items: center; gap: 14px; padding: 16px 18px;
  cursor: pointer; user-select: none;
}
.provider-head:hover { background: rgba(255, 255, 255, 0.014); }
.pv-icon {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-weight: 800; font-size: 14px;
  background: rgba(91, 140, 255, 0.1); color: #8fb0ff; border: 1px solid rgba(91, 140, 255, 0.18);
}
.pv-main { min-width: 0; flex: 1; }
.pv-name { font-size: 14px; font-weight: 620; display: flex; align-items: center; gap: 8px; }
.pv-url { font-size: 11.5px; color: var(--text-faint); font-family: var(--mono); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-metrics { display: flex; gap: 22px; padding-right: 6px; }
.pv-metric { text-align: right; }
.pv-metric b { display: block; font-size: 14px; font-weight: 620; font-variant-numeric: tabular-nums; }
.pv-metric span { font-size: 10.5px; color: var(--text-faint); }
.chevron { transition: transform 0.2s; color: var(--text-faint); }
.chevron.open { transform: rotate(180deg); }
.provider-body { border-top: 1px solid var(--line-soft); padding: 14px 18px 16px; background: rgba(0, 0, 0, 0.16); }

/* ───────── key 行 ───────── */
.key-row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px; border-radius: 9px; border: 1px solid transparent;
  transition: background 0.12s;
}
.key-row:hover { background: rgba(255, 255, 255, 0.028); border-color: var(--line-soft); }
.key-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.key-dot.ok { background: var(--accent); box-shadow: 0 0 8px rgba(18, 224, 167, 0.6); }
.key-dot.bad { background: var(--danger); }
.key-dot.off { background: #4b5162; }
.key-dot.cool { background: var(--warn); animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
.key-name { font-size: 12.5px; min-width: 90px; color: var(--text-dim); }
.key-val { font-family: var(--mono); font-size: 12px; color: #b9c0d2; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key-stat { font-size: 11px; color: var(--text-faint); white-space: nowrap; }
.key-err { font-size: 11px; color: rgba(255, 107, 120, 0.85); max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ───────── 空状态 ───────── */
.empty { text-align: center; padding: 48px 20px; color: var(--text-faint); }
.empty-icon {
  width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 13px;
  background: rgba(255, 255, 255, 0.03); border: 1px solid var(--line);
  display: grid; place-items: center; color: var(--text-faint);
}
.empty-title { font-size: 13.5px; color: var(--text-dim); font-weight: 550; margin-bottom: 4px; }
.empty-desc { font-size: 12.5px; max-width: 340px; margin: 0 auto 16px; line-height: 1.6; }

/* ───────── 模态框 ───────── */
.overlay {
  position: fixed; inset: 0; background: rgba(4, 5, 8, 0.72);
  backdrop-filter: blur(4px); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 6vh 20px 20px; overflow-y: auto;
  animation: fade 0.16s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  width: 100%; max-width: 520px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; box-shadow: 0 30px 90px -20px rgba(0, 0, 0, 0.95);
  animation: pop 0.18s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(8px) scale(0.985); opacity: 0; } }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-title { font-size: 15.5px; font-weight: 640; letter-spacing: -0.2px; }
.modal-desc { font-size: 12.5px; color: var(--text-faint); margin-top: 3px; line-height: 1.5; }
.modal-body { padding: 18px 20px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 9px;
  padding: 14px 20px; border-top: 1px solid var(--line-soft);
  background: rgba(0, 0, 0, 0.2); border-radius: 0 0 16px 16px;
}
.x-btn { background: none; border: none; color: var(--text-faint); cursor: pointer; padding: 4px; border-radius: 6px; line-height: 0; }
.x-btn:hover { background: rgba(255, 255, 255, 0.06); color: var(--text); }

/* ───────── Toast ───────── */
.toast-root { position: fixed; top: 18px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  display: flex; align-items: center; gap: 9px;
  background: #171b24; border: 1px solid var(--line);
  padding: 11px 15px; border-radius: 10px; font-size: 13px;
  box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.9);
  animation: slideIn 0.22s ease; max-width: 380px;
  border-left: 2px solid var(--accent);
}
.toast.err { border-left-color: var(--danger); }
.toast.warn { border-left-color: var(--warn); }
@keyframes slideIn { from { transform: translateX(20px); opacity: 0; } }

/* ───────── 其他 ───────── */
.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar .spacer { flex: 1; }
.search-input { width: 230px; }
.seg { display: inline-flex; background: #0b0d12; border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg button {
  border: none; background: none; padding: 5px 12px; border-radius: 7px;
  font-size: 12.5px; color: var(--text-dim); cursor: pointer; transition: all 0.14s;
}
.seg button.active { background: var(--panel-2); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); }
.code-block {
  background: #08090d; border: 1px solid var(--line-soft); border-radius: 9px;
  padding: 12px 14px; font-family: var(--mono); font-size: 12px; line-height: 1.7;
  color: #b8c0d4; overflow-x: auto; white-space: pre;
}
.code-block .tok-k { color: #7ba2ff; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.kv:last-child { border-bottom: none; }
.kv span:first-child { color: var(--text-faint); }
.kv span:last-child { color: var(--text); font-weight: 500; text-align: right; }
.spin {
  width: 14px; height: 14px; border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent); border-radius: 50%; animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-box { padding: 40px; display: grid; place-items: center; }
.check-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  border-radius: 8px; cursor: pointer; transition: background 0.12s;
}
.check-item:hover { background: rgba(255, 255, 255, 0.03); }
.check-item input[type="checkbox"] { accent-color: var(--accent); width: 15px; height: 15px; cursor: pointer; }
.model-scroll { max-height: 46vh; overflow-y: auto; border: 1px solid var(--line-soft); border-radius: 10px; background: rgba(0, 0, 0, 0.18); }
.chart { width: 100%; height: 150px; display: block; }
.pill-count { font-size: 11px; color: var(--text-faint); }

@media (max-width: 1080px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto;
    flex-direction: row; overflow-x: auto; padding: 8px; z-index: 50;
    border-right: none; border-top: 1px solid var(--line);
    background: rgba(9, 11, 15, 0.96);
  }
  .side-brand, .nav-label, .side-foot { display: none; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 10px; padding: 6px 10px; flex-shrink: 0; }
  .nav-item .badge-dot { display: none; }
  .content { padding: 16px 14px 100px; }
  .topbar { padding: 13px 16px; }
  .stat-grid { gap: 10px; }
  .stat-value { font-size: 22px; }
  .pv-metrics { display: none; }
  .row-2 { grid-template-columns: 1fr; }
  .search-input { width: 100%; }
}
