/* Crant AI Studio - Main Styles
 * Minimal overrides - design system is in themes.css
 */

/* Page-specific styles that don't belong in the design system */

/* Login Page */
.login-container {
  position: relative;
  width: 100%;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

.login-bg::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, var(--brand-blue) 0%, transparent 40%);
  opacity: 0.08;
  animation: bgFloat 20s ease-in-out infinite;
}

@keyframes bgFloat {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(2%, -2%) rotate(1deg); }
  66% { transform: translate(-1%, 1%) rotate(-1deg); }
}

.login-bg .grid {
  position: absolute;
  width: 100%;
  height: 100%;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 60px 60px;
  opacity: 0.3;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  padding: 48px 40px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 32px;
  box-shadow: var(--shadow-login);
  animation: cardAppear 0.6s ease-out;
}

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.logo-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 20px;
  background: var(--primary);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 12px 16px -4px rgba(36,36,36,0.12);
}

.logo-icon svg {
  width: 32px;
  height: 32px;
  color: var(--primary-foreground);
}

.logo h1 {
  font-size: 28px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 8px;
  letter-spacing: -0.04em;
}

.logo p {
  font-size: 14px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.login-form {
  margin-bottom: 32px;
}

.login-form .divider {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.login-form .divider::before,
.login-form .divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-form .divider span {
  padding: 0 16px;
}

.login-btn {
  width: 100%;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  box-shadow: var(--shadow-button);
}

.login-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(24,30,37,0.16);
  text-decoration: none;
}

.login-btn:active {
  transform: scale(0.98);
}

.login-footer {
  text-align: center;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}

.login-footer p {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 16px;
}

.login-footer .links {
  display: flex;
  justify-content: center;
  gap: 24px;
}

.login-footer .links a {
  font-size: 12px;
  color: var(--muted-foreground);
  text-decoration: none;
  transition: color 0.15s;
}

.login-footer .links a:hover {
  color: var(--brand-blue);
}

/* Docs tabs */
.docs-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 20px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0;
  overflow-x: auto;
}

.docs-tab {
  padding: 10px 16px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted-foreground);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}

.docs-tab:hover {
  color: var(--foreground);
}

.docs-tab.active {
  color: var(--foreground);
  border-bottom-color: var(--brand-blue);
}

/* Balance page */
.balance-current {
  text-align: center;
  padding: 32px 0;
}

.balance-current .label {
  display: block;
  font-size: 14px;
  color: var(--muted-foreground);
  margin-bottom: 8px;
}

.balance-current .amount {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

/* Group info card */
.group-info-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

.group-header {
  margin-bottom: 16px;
}

.group-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.group-name-row svg {
  color: var(--brand-blue);
  flex-shrink: 0;
}

.group-name {
  font-size: 18px;
  font-weight: 600;
}

.group-desc {
  font-size: 13px;
  color: var(--muted-foreground);
  display: block;
  margin-left: 28px;
}

.group-rules {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rule-item {
  padding: 10px 14px;
  background: var(--background);
  border-radius: 8px;
  font-size: 14px;
}

.rule-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.rule-label {
  color: var(--text-secondary, var(--muted-foreground));
}

.rule-value {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.rule-bar-bg {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.rule-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* User group rule list */
.rules-list {
  margin-bottom: 16px;
}

.rule-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 6px;
}

.rule-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 14px;
}

.rule-row-type {
  background: var(--background);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.rule-row-value strong {
  font-variant-numeric: tabular-nums;
}

.rule-add-form {
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 14px;
}

.rule-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.rule-add-label {
  font-size: 13px;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.rule-presets {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted-foreground);
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--border);
  border-radius: 22px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  height: 16px;
  width: 16px;
  left: 3px;
  bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--brand-blue, #3b82f6);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

/* Personal limits */
.limits-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}

.limit-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.limit-label {
  font-size: 13px;
  color: var(--muted-foreground);
}

.limit-value {
  font-size: 24px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* Responsive mobile */
@media (max-width: 480px) {
  .login-card {
    margin: 20px;
    padding: 32px 24px;
  }

  .logo h1 {
    font-size: 24px;
  }

  .logo-icon {
    width: 56px;
    height: 56px;
  }
}

/* Docs page mobile */
@media (max-width: 640px) {
  .docs-container {
    flex-direction: column;
  }

  .docs-sidebar {
    width: 100% !important;
    position: static !important;
    display: flex;
    gap: 4px;
    padding: 8px !important;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .docs-sidebar::-webkit-scrollbar {
    display: none;
  }

  .docs-nav-item {
    white-space: nowrap;
    flex-shrink: 0;
  }

  .docs-content {
    min-width: 0;
  }
}

/* Redeem code inputs */
.redeem-code-inputs {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.redeem-code-char {
  width: 40px;
  height: 48px;
  text-align: center;
  font-size: 24px;
  font-weight: 600;
  font-family: 'SF Mono', 'Monaco', 'Menlo', 'Consolas', monospace;
  text-transform: uppercase;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--muted);
  color: var(--foreground);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.redeem-code-char:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.redeem-code-char.filled {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

@media (max-width: 480px) {
  .redeem-code-char {
    width: 32px;
    height: 40px;
    font-size: 20px;
  }

  .redeem-code-inputs {
    gap: 6px;
  }
}

/* CrewRouter Team 管理样式 */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.team-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  transition: box-shadow 0.2s;
}

.team-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.team-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.team-card-header h3 {
  margin: 0;
  font-size: 16px;
}

.team-description {
  color: var(--muted-foreground);
  font-size: 14px;
  margin: 0 0 12px;
  min-height: 20px;
}

.team-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.provider-group {
  margin-bottom: 16px;
}

.provider-group h4 {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--muted-foreground);
}

.model-list {
  display: grid;
  gap: 8px;
}

.model-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--muted);
  border-radius: 8px;
}

.model-item.disabled {
  opacity: 0.6;
}

.model-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.model-name {
  font-weight: 500;
  font-size: 14px;
}

.model-id {
  font-size: 12px;
  color: var(--muted-foreground);
}

.model-actions {
  display: flex;
  gap: 6px;
}

/* CrewRouter 模型库样式 - 优化版 */

/* 页面头部 */
.model-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.model-library-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 筛选栏 */
.model-filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.model-search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}

.model-search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}

.model-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card);
  font-size: 13px;
  transition: all 0.15s;
}

.model-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.model-filter-selects {
  display: flex;
  gap: 8px;
}

.model-filter-selects .select {
  font-size: 13px;
  padding: 7px 10px;
  min-width: 100px;
}

.library-reorder-mode-active {
  border-color: var(--primary) !important;
  color: var(--primary) !important;
  background: rgba(59, 130, 246, 0.08) !important;
}

.library-reorder-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 4px;
}

.library-drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  cursor: grab;
  color: var(--muted-foreground);
  font-size: 16px;
  line-height: 1;
  user-select: none;
  border-radius: 4px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.library-drag-handle:hover {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

.library-drag-handle:active {
  cursor: grabbing;
}

.model-library-team.library-dragging,
.model-library-provider.library-dragging,
.model-library-item.library-dragging {
  opacity: 0.4;
}

.model-library-team.library-drag-over > .model-library-team-header,
.model-library-provider.library-drag-over,
.model-library-item.library-drag-over {
  border-top: 2px solid var(--primary) !important;
}

.model-library-team.library-drag-over {
  border-top: 2px solid var(--primary);
}

.model-library-provider.library-drag-over {
  border-top: 2px solid var(--primary);
}

/* 供应商额度卡片 */
.model-quota-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.model-quota-card.error {
  border-color: var(--destructive);
}

.model-quota-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.model-quota-name {
  font-weight: 600;
  font-size: 14px;
}

.model-quota-plan {
  font-size: 12px;
  color: var(--muted-foreground);
}

.model-quota-numbers {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.model-quota-remaining {
  font-size: 22px;
  font-weight: 700;
}

.model-quota-total {
  font-size: 12px;
  color: var(--muted-foreground);
}

.model-quota-bar {
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.model-quota-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s ease;
}

.model-quota-pct {
  text-align: right;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted-foreground);
}

/* 供应商额度 */
.model-quota-section {
  margin-bottom: 20px;
}

.model-quota-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

/* 搜索和筛选栏 */
.model-filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}

.model-search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.model-search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted-foreground);
  pointer-events: none;
}

.model-search-input {
  width: 100%;
  padding: 10px 12px 10px 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  font-size: 14px;
  transition: all 0.15s;
}

.model-search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.model-filter-actions {
  display: flex;
  gap: 8px;
}

/* 当前模型徽章 */
.current-model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid var(--primary);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--primary);
}

/* 模型库 Key 选择器 */
.model-library-key-selector {
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.model-library-key-selector-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.model-library-key-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
  flex-shrink: 0;
}

.model-library-key-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 2px 0;
  flex: 1;
  min-width: 0;
}

.model-library-key-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  background: var(--background);
  color: var(--foreground);
  transition: all 0.15s ease;
  flex-shrink: 0;
  user-select: none;
}

.model-library-key-chip:hover {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.05);
}

.model-library-key-chip.active {
  border-color: var(--primary);
  background: rgba(59, 130, 246, 0.12);
  color: var(--primary);
  font-weight: 500;
}

.model-library-key-chip .key-prefix {
  font-family: monospace;
  font-size: 11px;
}

.model-library-key-chip .key-name {
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.model-library-key-chip .key-system-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(255, 193, 7, 0.15);
  color: #f59e0b;
}

.model-library-key-chip .key-model-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.key-tag-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* 一键展开/折叠下拉菜单 */
.expand-dropdown {
  position: relative;
  display: inline-block;
}

.expand-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 170px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 100;
  padding: 4px;
  overflow: hidden;
}

.expand-dropdown-item {
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 6px;
  transition: background 0.12s;
  white-space: nowrap;
}

.expand-dropdown-item:hover {
  background: var(--muted);
}

.expand-dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

#expandAllIcon {
  transition: transform 0.2s ease;
}

/* 模型库层级布局 */
.model-library-grid {
  display: grid;
  gap: 24px;
}

.model-library-team {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
}

.model-library-team-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.model-library-team-header:hover {
  background: var(--muted-hover, rgba(0,0,0,0.06));
}

.model-library-team-header h3 {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

/* 折叠图标 */
.collapse-icon {
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

/* 折叠状态 */
.model-library-team.collapsed .collapse-icon,
.model-library-provider.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.model-library-team.collapsed .model-library-team-content {
  display: none;
}

.model-library-provider.collapsed .model-library-list {
  display: none;
}

/* 供应商未加载模型明细时的占位提示 */
.model-library-placeholder {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  color: var(--muted-foreground);
  font-size: 13px;
}
.model-library-placeholder .placeholder-text {
  opacity: 0.8;
}
.model-library-placeholder a {
  color: var(--primary);
  cursor: pointer;
}

.team-badge {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--primary);
  color: white;
  border-radius: 6px;
  font-weight: 500;
}

.team-badge.default {
  background: var(--muted-foreground);
}

/* 供应商分组 */
.model-library-provider {
  border-bottom: 1px solid var(--border);
}

.model-library-provider:last-child {
  border-bottom: none;
}

.model-library-provider-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(0, 0, 0, 0.02);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.model-library-provider-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
  flex-wrap: wrap;
}

.model-library-provider-title .provider-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-library-provider-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.model-library-provider-header:hover {
  background: rgba(0, 0, 0, 0.04);
}

.provider-model-count {
  font-size: 12px;
  font-weight: 400;
  color: var(--muted-foreground);
}

.provider-test-summary {
  display: inline-block;
  max-width: min(360px, 100%);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  cursor: default;
}

.provider-test-summary.pass {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.provider-test-summary.fail {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.provider-test-summary.mixed {
  background: rgba(234, 179, 8, 0.12);
  color: #a16207;
  border: 1px solid rgba(234, 179, 8, 0.25);
}

.provider-test-summary.untested {
  background: rgba(148, 163, 184, 0.12);
  color: var(--muted-foreground);
  border: 1px solid rgba(148, 163, 184, 0.22);
}

/* 模型列表 - 网格布局 */
.model-library-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  padding: 16px;
}

.model-library-item {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--background);
}

.model-library-item:hover {
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.model-library-item.selected {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--primary);
}

.model-library-item-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.model-library-item-name {
  font-weight: 600;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.model-library-item-name img {
  width: 16px;
  height: 16px;
  object-fit: contain;
  border-radius: 3px;
}

.model-item-badges {
  display: inline-flex;
  gap: 4px;
  flex-wrap: wrap;
}

.model-item-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
}

.model-item-badge.series {
  background: var(--muted);
  color: var(--muted-foreground);
}

.model-item-badge.owner {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary);
}

.model-library-item-desc {
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.model-library-item-price {
  font-size: 12px;
  color: var(--muted-foreground);
  display: flex;
  gap: 10px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.model-price-item {
  display: flex;
  gap: 4px;
}

.model-price-label {
  opacity: 0.7;
}

.model-price-value {
  font-weight: 500;
}

.model-library-item-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
}

.model-library-item-actions .btn {
  font-size: 12px;
  padding: 6px 14px;
}

/* 响应式 */
@media (max-width: 768px) {
  .model-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .model-search-box {
    max-width: none;
  }

  .model-quota-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }

  .model-library-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .model-library-item-actions {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .provider-preset-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}

/* 供应商列表 */
.provider-list-container {
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}

.provider-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 1px solid var(--border);
}

.provider-list-item:last-child {
  border-bottom: none;
}

.provider-list-item:hover {
  background: var(--muted);
}

.provider-list-item.custom {
  background: var(--muted);
  font-weight: 500;
}

.provider-list-item.custom:hover {
  background: var(--muted-hover, rgba(0,0,0,0.06));
}

.provider-list-name {
  font-weight: 500;
  font-size: 14px;
}

.provider-list-url {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* 向导步骤 */
.provider-step {
  animation: fadeIn 0.2s ease;
}

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

/* 用户供应商管理 */
.my-providers-section {
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.my-providers-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}

.my-providers-header:hover {
  background: var(--muted-hover, rgba(0,0,0,0.06));
}

.my-providers-list {
  padding: 12px;
}

.my-providers-section.collapsed .my-providers-list {
  display: none;
}

.my-providers-section.collapsed .collapse-icon {
  transform: rotate(-90deg);
}

.my-provider-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 4px;
}

.my-provider-item:last-child {
  margin-bottom: 0;
}

.my-provider-item:hover {
  background: var(--muted);
}

.my-provider-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.my-provider-name {
  font-weight: 500;
  font-size: 14px;
}

.my-provider-url {
  font-size: 12px;
  color: var(--muted-foreground);
}

.my-provider-actions {
  display: flex;
  gap: 6px;
}

.my-provider-actions .btn {
  font-size: 12px;
  padding: 4px 10px;
}

/* 模型选择项 */
.model-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}

.model-check-item:last-child {
  border-bottom: none;
}

.model-check-item:hover {
  background: var(--muted);
}

.model-check-item input[type="checkbox"] {
  flex-shrink: 0;
}

/* ========== Toggle Switch ========== */
.pg-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.pg-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.pg-toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 20px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.15);
}

.pg-toggle-slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: var(--muted-foreground, #94a3b8);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.pg-toggle input:checked + .pg-toggle-slider {
  background: var(--brand-blue, #3b82f6);
  border-color: transparent;
  box-shadow: none;
}

.pg-toggle input:checked + .pg-toggle-slider:before {
  transform: translateY(-50%) translateX(16px);
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.pg-toggle:active .pg-toggle-slider:before {
  width: 16px;
}

.pg-toggle:has(input:checked):active .pg-toggle-slider:before {
  transform: translateY(-50%) translateX(14px);
}

.pg-toggle:hover .pg-toggle-slider {
  border-color: rgba(255, 255, 255, 0.15);
}

.pg-toggle:has(input:checked):hover .pg-toggle-slider {
  border-color: transparent;
  background: #2563eb;
}

.pg-toggle input:focus-visible + .pg-toggle-slider {
  box-shadow: 0 0 0 2px var(--brand-blue, #3b82f6), 0 0 0 4px rgba(59, 130, 246, 0.25);
}

.pg-toggle input:disabled + .pg-toggle-slider {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================
   Admin: 统计概览卡片
   ============================================ */
.admin-stat-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.admin-stat-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 18px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--card);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.admin-stat-card:hover {
  border-color: var(--brand-blue);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.08);
}

.admin-stat-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.admin-stat-card-icon.blue  { background: rgba(59, 130, 246, 0.1); color: #3b82f6; }
.admin-stat-card-icon.green { background: rgba(34, 197, 94, 0.1);  color: #22c55e; }
.admin-stat-card-icon.amber { background: rgba(245, 158, 11, 0.1); color: #f59e0b; }
.admin-stat-card-icon.purple { background: rgba(139, 92, 246, 0.1); color: #8b5cf6; }
.admin-stat-card-icon.rose  { background: rgba(244, 63, 94, 0.1);  color: #f43f5e; }

.admin-stat-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.admin-stat-card-value {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--foreground);
}

.admin-stat-card-label {
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* ============================================
   Admin: 筛选栏
   ============================================ */
.admin-filter-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.admin-filter-bar .input {
  flex: 1;
  min-width: 180px;
}

.admin-filter-bar .select {
  min-width: 140px;
}

.admin-filter-bar .filter-info {
  font-size: 13px;
  color: var(--muted-foreground);
  white-space: nowrap;
  margin-left: auto;
}

/* ============================================
   Admin: 操作按钮下拉菜单
   ============================================ */
.admin-action-dropdown {
  position: relative;
  display: inline-block;
}

.admin-action-dropdown .dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 200px;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
}

.admin-action-dropdown.open .dropdown-menu {
  display: block;
  animation: fadeIn 0.12s ease;
}

.dropdown-menu .dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--foreground);
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  text-align: left;
  white-space: nowrap;
  transition: background 0.1s;
}

.dropdown-menu .dropdown-item:hover {
  background: var(--accent);
}

.dropdown-menu .dropdown-item.danger {
  color: var(--destructive);
}

.dropdown-menu .dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.08);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ============================================
   Admin: 空状态
   ============================================ */
.admin-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted-foreground);
}

.admin-empty-state svg {
  margin-bottom: 12px;
  opacity: 0.4;
}

.admin-empty-state p {
  font-size: 14px;
  margin: 0;
}

/* ============================================
   Admin: 表格增强
   ============================================ */
.users-table table,
.models-table table {
  width: 100%;
  border-collapse: collapse;
}

.users-table th,
.users-table td,
.models-table th,
.models-table td {
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}

.users-table th,
.models-table th {
  font-weight: 600;
  color: var(--muted-foreground);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  background: var(--muted);
  position: sticky;
  top: 0;
  z-index: 1;
}

.users-table tbody tr:hover,
.models-table tbody tr:hover {
  background: var(--accent);
}

/* ============================================
   Admin: 页面标题行增强
   ============================================ */
.admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.admin-page-header h2 {
  margin: 0;
  font-size: 20px;
}

.admin-page-header .section-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ============================================
   Admin: 响应式
   ============================================ */
@media (max-width: 834px) {
  .admin-stat-cards {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .admin-stat-cards {
    grid-template-columns: 1fr;
  }

  .admin-filter-bar {
    flex-direction: column;
  }

  .admin-filter-bar .input,
  .admin-filter-bar .select {
    width: 100%;
    min-width: auto;
  }

  .admin-filter-bar .filter-info {
    margin-left: 0;
  }
}

/* ========== Leaderboard (排行榜) ========== */
.leaderboard-table th {
  white-space: nowrap;
}
.leaderboard-rank-cell {
  text-align: center;
  vertical-align: middle;
}
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
}
.rank-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-foreground);
}
.leaderboard-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}
.leaderboard-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.leaderboard-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.leaderboard-username {
  font-weight: 500;
  font-size: 14px;
}
.leaderboard-stat-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.leaderboard-current-row {
  background: rgba(59, 130, 246, 0.06);
}
.leaderboard-current-row:hover td {
  background: rgba(59, 130, 246, 0.1) !important;
}
.leaderboard-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted-foreground);
  margin-top: 12px;
  padding: 8px;
}

/* ========== Model Testing (模型测试) ========== */
.model-test-btn {
  transition: opacity 0.2s;
}
.model-test-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.model-test-btn .spinner {
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: modelTestSpin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 2px;
}
@keyframes modelTestSpin {
  to { transform: rotate(360deg); }
}

.model-test-result-pass {
  color: #10b981;
  font-weight: 500;
}
.model-test-result-fail {
  color: var(--destructive);
  font-weight: 500;
}

.model-test-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.model-test-row:last-child {
  border-bottom: none;
}
.model-test-row-icon {
  width: 22px;
  text-align: center;
  flex-shrink: 0;
  font-size: 16px;
}
.model-test-row-model {
  flex: 1;
  min-width: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.model-test-row-model .provider-tag {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted-foreground);
  margin-left: 6px;
}
.model-test-row-stats {
  display: flex;
  gap: 16px;
  flex-shrink: 0;
}
.model-test-stat {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.model-test-stat-value {
  font-weight: 500;
}
.model-test-stat-label {
  font-size: 10px;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.model-test-row-error {
  color: var(--destructive);
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
}

.model-test-summary {
  display: flex;
  gap: 20px;
  padding: 12px 0 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.model-test-summary-item {
  text-align: center;
}
.model-test-summary-value {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.model-test-summary-label {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 2px;
}

/* Model test progress bar */
.model-test-progress {
  padding: 32px 8px;
  text-align: center;
}
.model-test-progress-bar {
  width: 100%;
  height: 8px;
  background: var(--muted);
  border-radius: 9999px;
  overflow: hidden;
  margin: 16px 0 12px;
}
.model-test-progress-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.3s ease;
  width: 0%;
}
.model-test-progress-text {
  font-size: 14px;
  color: var(--muted-foreground);
  margin: 0 0 4px;
}
.model-test-progress-count {
  font-size: 12px;
  color: var(--muted-foreground);
  opacity: 0.7;
}

/* Summary progress bar */
.model-test-summary-bar {
  width: 100%;
  height: 6px;
  background: var(--muted);
  border-radius: 9999px;
  overflow: hidden;
  margin: 8px 0 12px;
}
.model-test-summary-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: #10b981;
  transition: width 0.5s ease;
}

.model-test-batch-btn {
  position: relative;
}
.model-test-batch-btn .dropdown-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 180px;
  background: var(--popover);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
}
.model-test-batch-btn .dropdown-menu.show {
  display: block;
  animation: fadeIn 0.12s ease;
}

/* Model test status badge on model cards */
.model-test-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 4px;
  margin-left: 6px;
  vertical-align: middle;
  line-height: 1.6;
  cursor: default;
}
.model-test-badge.pass {
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border: 1px solid rgba(16, 185, 129, 0.2);
}
.model-test-badge.fail {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Model test indicator in admin table */
.model-test-indicator {
  font-size: 11px;
  font-weight: 500;
  cursor: default;
  white-space: nowrap;
}
.model-test-indicator.pass {
  color: #10b981;
}
.model-test-indicator.fail {
  color: var(--destructive);
}
