/* ===== Token 管理页面样式（双角色） ===== */

/* ---- 通用 ---- */
.tk-body { padding: 24px 0 60px; flex: 1; }
.tk-container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

/* 页头 */
.tk-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.tk-title { font-size: 22px; font-weight: 700; color: #111827; margin: 0 0 4px; }
.tk-subtitle { font-size: 14px; color: #6B7280; margin: 0; }
.tk-doc-link a, .tk-topbar-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 8px 16px;
  border: 1px solid #D1D5DB;
  border-radius: 8px;
  font-size: 13px;
  color: #4B5563;
  text-decoration: none;
  transition: all .15s;
  cursor: pointer;
  background: #fff;
  font-family: inherit;
}
.tk-doc-link a:hover, .tk-topbar-actions .btn:hover { border-color: #6366F1; color: #6366F1; background: #EEF2FF; }

/* 无权限/未登录 */
.tk-denied { display: flex; align-items: center; justify-content: center; min-height: 60vh; flex: 1; }
.tk-denied-box { text-align: center; }
.tk-denied-icon { font-size: 48px; margin-bottom: 16px; }
.tk-denied-title { font-size: 20px; font-weight: 700; color: #374151; margin-bottom: 8px; }
.tk-denied-desc { font-size: 14px; color: #9CA3AF; margin-bottom: 20px; }

/* 加载动画 */
.spin { width: 18px; height: 18px; border: 2px solid #E5E7EB; border-top-color: #6366F1; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.spin-lg { width: 32px; height: 32px; border: 3px solid #E5E7EB; border-top-color: #6366F1; border-radius: 50%; animation: spin .7s linear infinite; margin: 0 auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 按钮 ---- */
.tk-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 18px; border: 1px solid transparent; border-radius: 8px;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all .15s;
  font-family: inherit; line-height: 1.25;
}
.tk-btn:disabled { opacity: .55; cursor: not-allowed; }
.tk-btn-primary { background: #6366F1; color: #fff; border-color: #6366F1; }
.tk-btn-primary:hover:not(:disabled) { background: #4F46E5; box-shadow: 0 2px 8px rgba(99,102,241,.3); }
.tk-btn-danger { background: #fff; color: #E03131; border-color: #FECACA; }
.tk-btn-danger:hover:not(:disabled) { background: #fef2f2; border-color: #E03131; }
.tk-btn-outline { background: #fff; color: #4B5563; border-color: #D1D5DB; }
.tk-btn-outline:hover:not(:disabled) { border-color: #6366F1; color: #6366F1; background: #F9FAFB; }
.tk-btn-sm { padding: 4px 12px; font-size: 12px; }
.tk-btn-sm:hover:not(:disabled) { border-color: #6366F1; color: #6366F1; }
.tk-btn-lg { padding: 12px 32px; font-size: 15px; border-radius: 10px; font-weight: 600; }

/* 卡片 */
.tk-card {
  background: #fff; border: 1px solid #E5E7EB; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.04); overflow: hidden; margin-bottom: 20px;
}
.tk-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; border-bottom: 1px solid #F3F4F6;
  font-size: 14px; font-weight: 700; color: #374151;
}
.tk-tip { margin-top: 12px; font-size: 12px; color: #9CA3AF; line-height: 1.5; }
.tk-rule-hint { font-size: 12px; color: #9CA3AF; line-height: 1.5; margin-top: 12px; }

/* ==================== 普通用户视图 ==================== */

/* 用户信息条 */
.tk-user-bar {
  display: flex; align-items: center; padding: 12px 16px;
  background: linear-gradient(135deg, #EEF2FF, #FAFBFF);
  border: 1px solid #C7D2FE; border-radius: 10px; margin-bottom: 20px;
}
.tk-user-bar-info { display: flex; align-items: center; gap: 10px; font-size: 14px; font-weight: 500; color: #374151; }
.tk-user-bar-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, #6366F1, #4F46E5); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0;
}
.tk-user-bar-id { font-family: 'SF Mono', Monaco, monospace; font-size: 11px; color: #9CA3AF; background: rgba(99,102,241,.08); padding: 1px 7px; border-radius: 4px; }

/* 状态徽标 */
.tk-status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.tk-status-active { background: #D1FAE5; color: #065F46; }
.tk-status-none   { background: #FEF3C7; color: #92400E; }

/* 我的 Token 卡片（突出） */
.tk-my-token-card { border-color: #C7D2FE; box-shadow: 0 2px 12px rgba(99,102,241,.06); }
.tk-my-token-body { padding: 20px; }

/* Token 行 */
.tk-token-row { display: flex; align-items: baseline; margin-bottom: 14px; gap: 12px; }
.tk-token-row label { width: 70px; flex-shrink: 0; font-size: 13px; color: #6B7280; }

/* Token 值 */
.tk-token-value-wrap { display: flex; align-items: center; gap: 6px; flex: 1; min-width: 0; }
.tk-token-value {
  font-family: 'SF Mono','Menlo',Monaco,monospace; font-size: 12px; color: #4338CA;
  background: #EEF2FF; padding: 8px 12px; border-radius: 8px; word-break: break-all;
  flex: 1; line-height: 1.55; border: 1px solid #DDD6FE;
}
.tk-copy-btn {
  width: 34px; height: 34px; border: 1px solid #D1D5DB; border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 15px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.tk-copy-btn:hover { border-color: #6366F1; background: #EEF2FF; transform: scale(1.06); }
.tk-copy-btn.copied { border-color: #22C55E; background: #DCFCE7; }

/* 元数据网格 */
.tk-meta-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(160px,1fr)); gap: 12px; padding: 14px 0; border-top: 1px solid #F3F4F6; border-bottom: 1px solid #F3F4F6; margin-bottom: 14px; }
.tk-meta-item { display: flex; flex-direction: column; gap: 2px; }
.tk-meta-label { font-size: 11px; color: #9CA3AF; font-weight: 500; text-transform: uppercase; letter-spacing: .03em; }
.tk-meta-val { font-size: 13px; color: #374151; font-variant-numeric: tabular-nums; }

/* 操作按钮组 */
.tk-token-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }

/* 无 Token 状态 */
.tk-no-token { text-align: center; padding: 40px 24px 32px; }
.tk-no-token-icon { font-size: 44px; margin-bottom: 14px; }
.tk-no-token-text { font-size: 16px; font-weight: 600; color: #374151; margin-bottom: 8px; }
.tk-no-token-desc { font-size: 13px; color: #6B7280; margin-bottom: 20px; line-height: 1.6; max-width: 420px; margin-left: auto; margin-right: auto; }

/* ==================== 管理员视图 ==================== */

.tk-layout { display: flex; gap: 24px; align-items: flex-start; }
.tk-sidebar {
  width: 300px; flex-shrink: 0; background: #fff; border: 1px solid #E5E7EB;
  border-radius: 12px; box-shadow: 0 1px 4px rgba(0,0,0,.04); overflow: hidden; position: sticky; top: 80px;
}
.tk-sidebar-header { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; border-bottom: 1px solid #E5E7EB; background: #F9FAFB; }
.tk-sidebar-title { font-size: 14px; font-weight: 700; color: #374151; }
.tk-sidebar-count { font-size: 11px; color: #9CA3AF; }
.tk-user-list { max-height: calc(100vh - 240px); overflow-y: auto; }
.tk-user-item { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; border-bottom: 1px solid #F9FAFB; transition: background .12s; }
.tk-user-item:hover { background: #F5F3FF; }
.tk-user-item.active { background: #EEF2FF; }
.tk-user-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg,#6366F1,#4F46E5); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; flex-shrink: 0; }
.tk-user-info { flex: 1; min-width: 0; }
.tk-user-name { font-size: 14px; font-weight: 600; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tk-user-meta { font-size: 11px; color: #9CA3AF; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.self-tag { font-size: 10px; color: #6366F1; font-weight: 600; margin-left: 4px; }
.tk-token-badge { padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; flex-shrink: 0; white-space: nowrap; }
.tk-token-badge.has { background: #D1FAE5; color: #065F46; }
.tk-token-badge.none { background: #FEF3C7; color: #92400E; }
.tk-empty-users { text-align: center; padding: 32px 16px; font-size: 13px; color: #9CA3AF; }
.tk-loading-users { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 24px; }

/* 右侧主区 */
.tk-main { flex: 1; min-width: 0; }
.tk-detail-header { margin-bottom: 20px; }
.tk-detail-user { display: flex; align-items: center; gap: 12px; font-size: 14px; line-height: 1.6; color: #374151; }
.tk-detail-name { font-size: 15px; font-weight: 500; color: #111827; white-space: nowrap; }
.tk-detail-meta { font-size: 13px; color: #6B7280; white-space: nowrap; }
.tk-placeholder { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; border: 1px solid #E5E7EB; border-radius: 12px; min-height: 400px; color: #9CA3AF; font-size: 14px; }
.tk-placeholder-icon { font-size: 40px; margin-bottom: 12px; }

/* Token 信息 */
.tk-token-info { padding: 16px 18px; }

/* 自选股卡片 */
.tk-stocks-card { transition: box-shadow .2s; }
.tk-stocks-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.06); }
.tk-stocks-header { cursor: pointer; user-select: none; padding-right: 18px !important; transition: background .15s; }
.tk-stocks-header:hover { background: #F5F3FF; }
.tk-stocks-header.expanded { background: #EEF2FF; }
.tk-stocks-title-wrap { display: flex; align-items: center; gap: 6px; }
.tk-stocks-arrow { font-size: 14px; color: #9CA3AF; transition: transform .2s; display: inline-block; width: 14px; }
.tk-stocks-count-hint { font-size: 11px; color: #9CA3AF; background: #F3F4F6; padding: 1px 7px; border-radius: 10px; }
.tk-stocks-collapsed { text-align: center; padding: 16px; font-size: 13px; color: #9CA3AF; cursor: pointer; border-top: 1px solid #F9FAFB; }
.tk-stocks-expanded { position: relative; }
.tk-loading-overlay { position: absolute; inset: 0; z-index: 2; background: rgba(255,255,255,.85); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; gap: 8px; color: #6B7280; font-size: 13px; min-height: 120px; }
.tk-table { width: 100%; border-collapse: collapse; }
.tk-table th { text-align: left; padding: 8px 14px; font-size: 11px; font-weight: 600; color: #9CA3AF; background: #F9FAFB; border-bottom: 1px solid #E5E7EB; }
.tk-table td { padding: 8px 14px; font-size: 13px; color: #374151; border-bottom: 1px solid #F9FAFB; }
.tk-table code { font-family: 'SF Mono',Monaco,monospace; font-size: 12px; color: #6B7280; background: #F3F4F6; padding: 1px 6px; border-radius: 4px; }
.tk-sname { font-weight: 600; }
.up { color: #E03131 !important; }
.down { color: #2F9E44 !important; }
.tk-code-cell code { cursor: pointer; transition: all .15s; }
.tk-code-cell code:hover { color: #6366F1; background: #EEF2FF; }
.tk-stocks-footer { text-align: center; padding: 8px; font-size: 12px; color: #9CA3AF; border-top: 1px solid #F5F4F6; background: #FAFAFA; }
.tk-empty-stocks { text-align: center; padding: 28px; font-size: 13px; color: #9CA3AF; }

/* 接入指南 */
.tk-card-docs { background: linear-gradient(135deg,#FAFBFF,#F5F3FF); border-color: #C7D2FE; }
.tk-docs-header { display: flex; align-items: flex-start; gap: 14px; padding: 18px 20px 0; }
.tk-docs-icon { font-size: 32px; line-height: 1; flex-shrink: 0; margin-top: -2px; }
.tk-docs-title { font-size: 16px; font-weight: 700; color: #3730A3; margin: 0 0 2px; }
.tk-docs-subtitle { font-size: 13px; color: #6366F1; margin: 0; line-height: 1.45; }
.tk-docs-grid { padding: 16px 20px 8px; display: flex; flex-direction: column; gap: 10px; }
.tk-docs-row { display: flex; gap: 10px; }
.flex-1 { flex: 1; }
.tk-docs-field > label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #7C3AED; margin-bottom: 4px; }
.tk-docs-val { display: flex; align-items: center; gap: 6px; background: #fff; border: 1px solid #DDD6FE; border-radius: 8px; padding: 8px 10px; }
.tk-docs-val code { flex: 1; font-family: 'SF Mono',Monaco,monospace; font-size: 12px; color: #4338CA; word-break: break-all; line-height: 1.5; min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.tk-copy-inline { width: 26px; height: 26px; border: 1px solid #D1D5DB; border-radius: 6px; background: #fff; cursor: pointer; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all .15s; line-height: 1; }
.tk-copy-inline:hover { border-color: #6366F1; background: #EEF2FF; transform: scale(1.08); }
.tk-docs-curl { padding: 10px 20px 16px; }
.tk-docs-curl > label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #7C3AED; margin-bottom: 4px; }
.tk-code-block { background: #fff; border: 1px solid #FDE68A; border-radius: 6px; padding: 10px 14px; font-family: 'SF Mono',Monaco,monospace; font-size: 12px; color: #78350F; word-break: break-all; line-height: 1.6; margin: 8px 0; overflow-x: auto; }
.tk-code-sm { font-size: 11.5px !important; max-height: 60px; overflow-y: auto; }
.tk-skill-section { margin-top: 4px; border-top: 1px dashed #C7D2FE; padding: 14px 20px 18px; }
.tk-skill-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tk-skill-title span { font-size: 13px; font-weight: 700; color: #3730A3; }
.tk-skill-steps { margin: 0; padding-left: 20px; font-size: 13px; color: #4B5563; line-height: 1.85; }
.tk-skill-steps li { margin-bottom: 2px; }
.tk-skill-steps strong { color: #6366F1; font-weight: 600; }
.tk-skill-steps code { font-family: 'SF Mono',Monaco,monospace; font-size: 11.5px; background: #EEF2FF; padding: 1px 5px; border-radius: 4px; color: #4338CA; }

/* 表格行交互 */
.tk-table tbody tr { cursor: pointer; transition: background .12s; }
.tk-table tbody tr:hover { background: #F5F3FF; }
.tk-table tbody tr:active { background: #EDE9FE; }

/* Toast */
.toast-wrap {
  position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%);
  padding: 10px 24px; border-radius: 10px; font-size: 13px; font-weight: 500;
  z-index: 9999; animation: toastUp .3s ease; pointer-events: none;
}
.toast-success { background: #D1FAE5; color: #065F46; border: 1px solid #ABEFC6; }
.toast-error   { background: #FECACA; color: #991B1B; border: 1px solid #FCA5A5; }
.toast-info    { background: #DBEAFE; color: #1E40AF; border: 1px solid #93C5FD; }
@keyframes toastUp { from { opacity: 0; transform: translate(-50%, 16px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* 响应式 */
@media (max-width: 800px) {
  .tk-layout { flex-direction: column; }
  .tk-sidebar { width: 100%; position: static; max-height: 280px; }
  .tk-page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
  .tk-docs-row { flex-direction: column; }
  .tk-meta-grid { grid-template-columns: 1fr; }
  .tk-token-actions { flex-direction: column; }
  .tk-token-actions .tk-btn { width: 100%; }
}
