:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --text: #0f172a;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --error: #dc2626;
  --warning: #f59e0b;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.08);
  --transition: 200ms ease;
  --sidebar-w: 240px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 22px; }
h2 { font-size: 16px; }
h3 { font-size: 15px; margin: 16px 0 8px; }
p { margin: 0; }

.muted { color: var(--text-muted); }
[hidden] { display: none !important; }

code {
  background: #f1f5f9;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1px 6px;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  word-break: break-all;
}

/* ---------- 登录视图 ---------- */
.login-view { min-height: 100vh; display: flex; }

.login-hero {
  flex: 1 1 55%;
  background: linear-gradient(160deg, #0b1220 0%, #1e3a8a 55%, #2563eb 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 20%, rgba(96, 165, 250, 0.35), transparent 45%),
    radial-gradient(circle at 82% 78%, rgba(56, 189, 248, 0.25), transparent 42%);
}
.login-hero-inner { position: relative; max-width: 460px; }
.login-hero-inner h1 { font-size: 32px; margin: 18px 0 12px; color: #fff; }
.login-hero-sub { color: rgba(255, 255, 255, 0.85); font-size: 16px; margin-bottom: 26px; }
.login-hero-points {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 15px;
}
.login-hero-points li::before { content: '✓'; margin-right: 10px; color: #7dd3fc; font-weight: 700; }

.logo-mark {
  display: inline-block;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
}

.login-panel {
  flex: 1 1 45%;
  min-width: 340px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: #fff;
}
.login-card { width: 100%; max-width: 400px; }
.login-brand { margin-bottom: 24px; }
.login-brand h1 { font-size: 26px; margin: 0 0 4px; }

.logo-dot {
  display: inline-block;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #60a5fa);
}

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  font-size: 15px;
}
.sidebar-brand .logo-dot { width: 28px; height: 28px; border-radius: 8px; }

.sidebar-nav { padding: 12px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: block;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover { background: #f1f5f9; }
.nav-item.active { background: #eff6ff; color: var(--primary); font-weight: 600; }

.nav-group { margin-top: 10px; }
.nav-group-title {
  padding: 8px 12px 4px;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-title { font-weight: 650; font-size: 16px; }
.topbar-user { display: flex; align-items: center; gap: 12px; }

.content { padding: 24px 20px 48px; max-width: 1280px; width: 100%; margin: 0 auto; }

.view-panel { display: none; }
.view-panel.active { display: block; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header-row { display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 12px; }
.card-body { padding: 20px; }
.card.narrow { max-width: 560px; }

/* ---------- 统计 ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 14px;
}
.stat-card { padding: 16px 18px; }
.stat-label { color: var(--text-muted); font-size: 13px; margin-bottom: 6px; }
.stat-value { font-size: 20px; font-weight: 700; }

/* 首页图表 */
.home-chart-card { margin-top: 20px; }
.chart-wrap { position: relative; height: 300px; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
.field > span { font-weight: 550; }
.field small { font-weight: 400; }

input[type="text"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font: inherit;
  color: var(--text);
  background: #fff;
  transition: border-color var(--transition), box-shadow var(--transition);
}
textarea { resize: vertical; min-height: 80px; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.radio-row { display: flex; gap: 18px; }
.radio { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.form-error { color: var(--error); font-size: 14px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: #f1f5f9; }
.btn-xs { padding: 4px 10px; font-size: 12px; border-radius: 6px; }
.btn-danger-ghost { background: transparent; border-color: #fecaca; color: var(--error); }
.btn-danger-ghost:hover { background: #fef2f2; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  white-space: normal;
  word-break: break-all;
}
.table th { color: var(--text-muted); font-weight: 600; background: #f8fafc; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-warning { background: #fef3c7; color: #b45309; }

/* ---------- 分页 ---------- */
.pagination { display: flex; gap: 8px; align-items: center; margin-top: 14px; flex-wrap: wrap; }
.page-btn {
  min-width: 32px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition);
}
.page-btn:hover { background: #f1f5f9; }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.page-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- 额度 / 套餐 ---------- */
.quota-list { display: flex; flex-wrap: wrap; gap: 14px; }
.quota-card {
  padding: 18px 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  min-width: 160px;
}
.quota-card .quota-label { color: var(--text-muted); font-size: 13px; }
.quota-card .quota-value { font-size: 24px; font-weight: 700; margin-top: 4px; }

.package-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.package-card { padding: 20px; text-align: center; display: flex; flex-direction: column; gap: 10px; }
.package-card h3 { margin: 0; }
.package-money { font-size: 28px; font-weight: 700; color: var(--primary); }
.package-meta { font-size: 13px; color: var(--text-muted); }

/* ---------- 个人信息 / API ---------- */
.self-info { display: flex; flex-direction: column; gap: 10px; margin-bottom: 6px; }
.self-info p { display: flex; gap: 16px; align-items: baseline; }
.self-info .muted { width: 64px; flex: 0 0 64px; }
.divider { border: none; border-top: 1px solid var(--border); margin: 20px 0; }

.api-info { display: flex; flex-direction: column; gap: 12px; }
.api-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.api-row .muted { min-width: 130px; }
.api-docs h3 { margin-top: 20px; }

.api-tabs { display: flex; gap: 8px; flex-wrap: wrap; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.api-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  transition: color var(--transition), border-color var(--transition);
}
.api-tab:hover { color: var(--text); }
.api-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.api-callout { margin: 6px 0; }
.api-example {
  display: block;
  padding: 12px;
  margin: 8px 0 16px;
  background: #f8fafc;
  white-space: pre-wrap;
  word-break: break-all;
}
.api-section {
  text-align: center;
  margin: 20px 0 14px;
  font-weight: 650;
  color: #555;
  padding: 8px 15px;
  border-top: 2px solid var(--primary);
  border-bottom: 2px solid var(--primary);
  display: inline-block;
}
.api-resp-label { margin: 14px 0 6px; font-weight: 650; }
.api-resp-fail { color: var(--error); }
.api-resp-ok { color: var(--success); }
pre.api-pre {
  background: #0f172a;
  color: #e2e8f0;
  padding: 14px;
  border-radius: 8px;
  overflow-x: auto;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre;
}

/* ---------- 弹窗 ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal[hidden] { display: none !important; }
.modal-mask { position: absolute; inset: 0; background: rgba(15, 23, 42, 0.4); }
.modal-card { position: relative; width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }

/* ---------- 新增签名弹窗 ---------- */
.req { color: var(--error); margin-left: 2px; }
.notice {
  padding: 10px 12px;
  border-radius: 8px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
  line-height: 1.5;
}
.upload-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.upload-box { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.upload-preview {
  width: 100%;
  height: 110px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.upload-preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.upload-preview .upload-hint { color: var(--text-muted); font-size: 12px; padding: 0 8px; text-align: center; }
.upload-box input[type="file"] { width: 100%; font-size: 12px; }
@media (max-width: 560px) {
  .upload-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 1024px) {
  .stats-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .login-hero { display: none; }
  .login-panel { flex: 1; min-width: 0; }
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%;
    flex: 0 0 auto;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { flex: 0 0 auto; }
  .nav-group { margin-top: 0; width: 100%; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-user .muted { display: none; }
}
