/* ============================================================
   全局设计系统 — 深色主题
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
  --bg-base: #080c18;
  --bg-surface: #0f1629;
  --bg-card: #141c30;
  --bg-card-hover: #1a2440;
  --bg-input: #0d1525;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99,102,241,0.3);
  --cyan: #06b6d4;
  --green: #10b981;
  --amber: #f59e0b;
  --red: #ef4444;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #475569;
  --border: rgba(255,255,255,0.07);
  --border-accent: rgba(99,102,241,0.4);
  --shadow: 0 8px 32px rgba(0,0,0,0.4);
  --shadow-lg: 0 20px 60px rgba(0,0,0,0.6);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============================================================
   登录页
   ============================================================ */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

.bg-animation {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.25;
  animation: float 8s ease-in-out infinite;
}
.orb-1 { width: 500px; height: 500px; background: #6366f1; top: -100px; left: -150px; animation-delay: 0s; }
.orb-2 { width: 400px; height: 400px; background: #06b6d4; bottom: -80px; right: -100px; animation-delay: -3s; }
.orb-3 { width: 300px; height: 300px; background: #8b5cf6; top: 50%; left: 50%; transform: translate(-50%,-50%); animation-delay: -5s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}
.orb-3 { animation: float3 10s ease-in-out infinite; }
@keyframes float3 {
  0%, 100% { transform: translate(-50%,-50%) scale(1); }
  50% { transform: translate(-50%,-50%) scale(1.1); }
}

.login-container {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 24px;
  animation: slideUp 0.6s cubic-bezier(0.16,1,0.3,1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card {
  background: rgba(20, 28, 48, 0.85);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(99,102,241,0.1);
}

.login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.logo-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, #6366f1, #06b6d4);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 24px var(--accent-glow);
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 表单 */
.login-form { display: flex; flex-direction: column; gap: 18px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }

.form-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper { position: relative; }

.input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  pointer-events: none;
  opacity: 0.7;
}

.form-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px 12px 42px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.error-message {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  text-align: center;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #4f46e5);
  color: #fff;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 6px 24px var(--accent-glow);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); }

.btn-full { width: 100%; padding: 13px 20px; font-size: 15px; }

.btn-success { background: linear-gradient(135deg, var(--green), #059669); color: #fff; box-shadow: 0 4px 12px rgba(16,185,129,0.3); }
.btn-success:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16,185,129,0.4); }

.btn-danger  { background: rgba(239,68,68,0.12); color: #fca5a5; border: 1px solid rgba(239,68,68,0.25); }
.btn-danger:hover:not(:disabled)  { background: rgba(239,68,68,0.2); }

.btn-ghost   { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover:not(:disabled)  { background: rgba(255,255,255,0.08); color: var(--text-primary); }

.btn-icon { background: rgba(255,255,255,0.05); color: var(--text-secondary); border: 1px solid var(--border); padding: 8px 10px; }
.btn-icon:hover { background: rgba(255,255,255,0.1); color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   仪表盘布局
   ============================================================ */
.navbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 64px;
  background: rgba(15, 22, 41, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  z-index: 100;
  gap: 16px;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
}

.nav-logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.nav-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
}

.nav-subtitle {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 1px;
}

.navbar-actions { display: flex; align-items: center; gap: 12px; }

.admin-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-dot {
  width: 8px;
  height: 8px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 6px var(--green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.main-content {
  padding: 88px 28px 40px;
  max-width: 1300px;
  margin: 0 auto;
}

/* 统计卡片 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

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

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s, transform 0.2s;
  animation: fadeIn 0.5s ease both;
}

.stat-card:hover { border-color: var(--border-accent); transform: translateY(-2px); }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.indigo  { background: rgba(99,102,241,0.15); }
.stat-icon.cyan    { background: rgba(6,182,212,0.15); }
.stat-icon.green   { background: rgba(16,185,129,0.15); }
.stat-icon.amber   { background: rgba(245,158,11,0.15); }
.stat-icon.purple  { background: rgba(139,92,246,0.15); }

.stat-info { flex: 1; min-width: 0; }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -1px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* 内容区 */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
}

.section-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-left: 8px;
  font-weight: 400;
}

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead tr {
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid var(--border);
}

th {
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.02); }

td {
  padding: 14px 16px;
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* Token 显示 */
.token-display {
  display: flex;
  align-items: center;
  gap: 8px;
}

.token-code {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: var(--bg-input);
  padding: 4px 10px;
  border-radius: 6px;
  color: var(--cyan);
  border: 1px solid var(--border);
  letter-spacing: 1px;
}

.copy-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}

.copy-btn:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
.copy-btn.copied { color: var(--green); }

/* 徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-active   { background: rgba(16,185,129,0.12); color: #6ee7b7; border: 1px solid rgba(16,185,129,0.25); }
.badge-inactive { background: rgba(239,68,68,0.1);  color: #fca5a5; border: 1px solid rgba(239,68,68,0.2); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* 进度条（使用次数） */
.use-progress { display: flex; align-items: center; gap: 8px; }

.progress-bar {
  flex: 1;
  max-width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--cyan));
  border-radius: 2px;
  transition: width 0.4s;
}

.progress-fill.danger { background: linear-gradient(90deg, var(--amber), var(--red)); }

.use-text { font-size: 12px; color: var(--text-secondary); white-space: nowrap; }

/* 操作列 */
.action-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-icon { font-size: 40px; margin-bottom: 12px; }
.empty-text { font-size: 14px; }

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modalFade 0.2s ease;
}

@keyframes modalFade { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalSlide 0.25s cubic-bezier(0.16,1,0.3,1);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalSlide { from { opacity: 0; transform: scale(0.96) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-title { font-size: 16px; font-weight: 700; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.modal-close:hover { background: rgba(255,255,255,0.06); color: var(--text-primary); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* 表单控件（modal内） */
.form-row { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.form-row:last-child { margin-bottom: 0; }

.form-row label { font-size: 12px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; }

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-hint { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* 日志列表 */
.logs-modal .modal-card { max-width: 640px; }

.log-list { display: flex; flex-direction: column; gap: 8px; }

.log-item {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.log-num {
  width: 24px;
  height: 24px;
  background: rgba(99,102,241,0.15);
  color: var(--accent);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.log-info { flex: 1; min-width: 0; }
.log-ip   { font-size: 13px; font-weight: 600; color: var(--cyan); font-family: monospace; }
.log-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.log-ua   { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 380px; }

.logs-empty { text-align: center; padding: 40px; color: var(--text-muted); }

/* 命令展示框 */
.command-box {
  background: var(--bg-input);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.command-text {
  flex: 1;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  color: var(--cyan);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}

/* toast */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--bg-card);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: var(--shadow);
  z-index: 999;
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toastIn 0.3s cubic-bezier(0.16,1,0.3,1);
  max-width: 320px;
}

@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
.toast.out { animation: toastOut 0.3s ease forwards; }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }
