/* API 分发平台 - 共享样式（浅色主题） */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e6e9f2;
  --text: #1a2033;
  --text-2: #5a6478;
  --text-3: #9aa3b8;
  --primary: #4f46e5;
  --primary-2: #7c3aed;
  --primary-soft: #eef0ff;
  --success: #16a34a;
  --success-soft: #e8f7ee;
  --danger: #dc2626;
  --danger-soft: #fdecec;
  --warn: #d97706;
  --warn-soft: #fdf3e3;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(23, 30, 55, 0.04), 0 8px 24px rgba(23, 30, 55, 0.06);
  --shadow-lg: 0 4px 12px rgba(23, 30, 55, 0.08), 0 24px 64px rgba(23, 30, 55, 0.12);
  --font: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "Courier New", monospace;
}

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

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

button { font-family: inherit; }
input, textarea, select { font-family: inherit; color: inherit; }

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

/* ---------- 登录页 ---------- */
.login-wrap {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 46%) 1fr;
}
.login-brand {
  position: relative;
  background: linear-gradient(135deg, #4338ca 0%, #6d28d9 55%, #9333ea 100%);
  color: #fff;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}
.login-brand::before {
  content: "";
  position: absolute;
  width: 520px; height: 520px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  top: -180px; right: -160px;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 380px; height: 380px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  bottom: -140px; left: -120px;
}
.brand-logo {
  display: flex; align-items: center; gap: 12px;
  font-size: 20px; font-weight: 700;
  position: relative; z-index: 1;
}
.brand-logo .logo-ic {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.18);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(4px);
}
.brand-hero { position: relative; z-index: 1; }
.brand-hero h1 { font-size: 34px; font-weight: 800; line-height: 1.3; margin-bottom: 14px; }
.brand-hero p { font-size: 15px; opacity: 0.85; max-width: 420px; }
.brand-feats { position: relative; z-index: 1; display: grid; gap: 12px; }
.brand-feat {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; opacity: 0.92;
}
.brand-feat .dot {
  width: 26px; height: 26px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; flex-shrink: 0;
}
.login-side {
  display: flex; align-items: center; justify-content: center;
  padding: 40px 24px;
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
}
.login-card h2 { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.login-card .sub { color: var(--text-2); font-size: 13px; margin-bottom: 26px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.input, textarea.input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: #fbfcfe;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
  background: #fff;
}
textarea.input { resize: vertical; min-height: 90px; line-height: 1.7; }
.input.mono { font-family: var(--mono); font-size: 13px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: #c9cede; background: #f8f9fd; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  border-color: transparent;
  color: #fff;
  box-shadow: 0 4px 14px rgba(79, 70, 229, 0.3);
}
.btn-primary:hover { filter: brightness(1.06); background: linear-gradient(135deg, var(--primary), var(--primary-2)); }
.btn-danger { color: var(--danger); border-color: #f6caca; background: var(--danger-soft); }
.btn-danger:hover { background: #fbdddd; border-color: #eeb0b0; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: #eef0f6; border-color: transparent; }

.form-error {
  display: none;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid #f3c4c4;
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}
.form-error.show { display: block; }

/* ---------- 布局 ---------- */
.app { display: none; min-height: 100vh; flex-direction: column; }
.app.show { display: flex; }
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 60px;
  display: flex; align-items: center; gap: 14px;
}
.topbar .logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.topbar .logo .logo-ic {
  width: 32px; height: 32px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), var(--primary-2));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.topbar .spacer { flex: 1; }
.topbar .who { color: var(--text-2); font-size: 13px; display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
}
.main { flex: 1; padding: 26px 28px 60px; max-width: 1160px; width: 100%; margin: 0 auto; }
.page-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.page-sub { color: var(--text-2); font-size: 13px; margin-bottom: 22px; }

/* ---------- 卡片 / 统计 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 18px;
}
.card-head {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px;
}
.card-head h3 { font-size: 15.5px; font-weight: 700; }
.card-head .hint { color: var(--text-3); font-size: 12.5px; font-weight: 400; }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}
.stat .label { font-size: 12.5px; color: var(--text-2); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -0.5px; }
.stat .value small { font-size: 13px; color: var(--text-3); font-weight: 600; margin-left: 3px; }
.stat .ic {
  position: absolute; right: 14px; top: 14px;
  width: 34px; height: 34px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center; font-size: 16px;
}
.ic.violet { background: #f1edff; }
.ic.green { background: var(--success-soft); }
.ic.blue { background: #e7f1fe; }
.ic.amber { background: var(--warn-soft); }

/* 进度条 */
.progress {
  height: 8px; border-radius: 99px;
  background: #edeff6;
  overflow: hidden;
}
.progress .bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--primary-2));
  transition: width 0.4s;
}
.progress .bar.danger { background: linear-gradient(90deg, #ef4444, #dc2626); }
.progress .bar.warn { background: linear-gradient(90deg, #f59e0b, #d97706); }

/* 密钥展示 */
.key-row {
  display: flex; align-items: center; gap: 10px;
  background: #f7f8fc;
  border: 1px dashed #d4d9e8;
  border-radius: 10px;
  padding: 11px 14px;
  margin-bottom: 10px;
}
.key-row .key-text {
  font-family: var(--mono);
  font-size: 13px;
  flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: #3b4256;
}
.key-row .key-name { font-size: 12px; color: var(--text-3); flex-shrink: 0; }

.copy-box {
  display: flex; align-items: center; gap: 10px;
  background: #f7f8fc;
  border: 1px solid #e3e7f0;
  border-radius: 10px;
  padding: 10px 14px;
}
.copy-box .val { font-family: var(--mono); font-size: 13px; flex: 1; word-break: break-all; }

/* 模型 chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid #dcdeff;
  font-size: 12.5px; font-weight: 600;
  padding: 4px 12px;
  border-radius: 99px;
  font-family: var(--mono);
}
.empty { color: var(--text-3); font-size: 13px; padding: 8px 0; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  font-size: 12px; font-weight: 700; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.4px;
  padding: 8px 10px;
  border-bottom: 1.5px solid var(--border);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 10px;
  border-bottom: 1px solid #f0f2f8;
  vertical-align: middle;
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: #fafbfe; }
.tbl .mono { font-family: var(--mono); font-size: 12.5px; }
.tbl .actions { display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px;
  border-radius: 99px;
}
.tag.ok { background: var(--success-soft); color: var(--success); }
.tag.off { background: #f0f1f5; color: var(--text-3); }
.tag.err { background: var(--danger-soft); color: var(--danger); }
.tag .dot2 { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.user-cell { display: flex; flex-direction: column; }
.user-cell b { font-weight: 700; }
.user-cell span { font-size: 12px; color: var(--text-3); }

.quota-cell { min-width: 150px; }
.quota-cell .txt { font-size: 12px; color: var(--text-2); margin-bottom: 4px; }

/* ---------- 迷你柱状图 ---------- */
.mini-chart { display: flex; align-items: flex-end; gap: 10px; height: 110px; padding-top: 8px; }
.mini-chart .col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.mini-chart .bar2 {
  width: 100%; max-width: 42px;
  background: linear-gradient(180deg, #8b83f0, var(--primary));
  border-radius: 6px 6px 2px 2px;
  min-height: 3px;
  position: relative;
}
.mini-chart .bar2:hover::after {
  content: attr(data-v);
  position: absolute; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  background: #1a2033; color: #fff;
  font-size: 11px; padding: 2px 8px; border-radius: 6px;
  white-space: nowrap; z-index: 5;
}
.mini-chart .lbl { font-size: 11px; color: var(--text-3); }

/* ---------- 模态框 ---------- */
.modal-mask {
  display: none;
  position: fixed; inset: 0;
  background: rgba(18, 22, 38, 0.45);
  backdrop-filter: blur(3px);
  z-index: 100;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  width: 100%; max-width: 440px;
  padding: 26px 28px;
  max-height: 88vh;
  overflow-y: auto;
  animation: pop 0.18s ease;
}
@keyframes pop { from { transform: scale(0.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { font-size: 17px; margin-bottom: 18px; }
.modal .modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: #1a2033; color: #fff;
  padding: 10px 20px;
  border-radius: 12px;
  font-size: 13.5px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  transition: transform 0.25s ease;
  max-width: 90vw;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast.err { background: #b91c1c; }

/* ---------- 提示条 ---------- */
.banner {
  display: flex; align-items: center; gap: 10px;
  background: var(--warn-soft);
  border: 1px solid #f3ddb0;
  color: #92600a;
  border-radius: 12px;
  padding: 10px 16px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* ---------- 标签页（管理端） ---------- */
.tabs { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 13.5px; font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  border: 1.5px solid transparent;
  background: transparent;
  transition: all 0.15s;
}
.tab:hover { background: #ecedf5; }
.tab.active { background: var(--primary-soft); color: var(--primary); border-color: #dcdcff; }
.tab-page { display: none; }
.tab-page.show { display: block; }

/* 分页 */
.load-more { text-align: center; padding: 12px 0 2px; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .main { padding: 18px 14px 50px; }
  .topbar { padding: 0 14px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .stat .value { font-size: 21px; }
}
