/* ==================== 管理后台样式 ==================== */
.admin-sidebar {
    width: 180px;
    background: var(--card-bg);
    border-right: 1px solid var(--border);
    padding: 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.admin-nav-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: transparent;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
}

.admin-nav-btn:hover {
    background: rgba(0, 113, 227, 0.1);
    color: var(--primary);
}

.admin-nav-btn.active {
    background: rgba(0, 113, 227, 0.1);
    color: var(--primary);
    font-weight: 500;
}

.admin-nav-btn svg {
    flex-shrink: 0;
}

/* 管理后台弹窗只有一个纵向滚动容器：右侧 admin-content。
   之前依赖 modal-content 的 max-height + flex 自动分配高度，生产浏览器里
   任务诊断页仍会被内容撑开。这里改成显式 grid：标题行自适应，内容行固定
   占满剩余高度，再让右侧内容区滚动，避免外层/内层互相吞滚轮事件。 */
#adminPanelModal {
    padding: 24px;
}

#adminPanelModal .admin-modal-content {
    width: min(1200px, calc(100vw - 48px));
    max-width: 1200px;
    height: calc(100vh - 48px);
    max-height: 90vh;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr);
    overflow: hidden;
}

#adminPanelModal .admin-modal-body {
    min-height: 0;
    height: 100%;
    padding: 0;
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    overflow: hidden;
}

#adminPanelModal .admin-sidebar {
    width: auto;
    min-height: 0;
    overflow-y: auto;
}

#adminPanelModal .admin-content {
    height: 100%;
    max-height: none;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
}

#adminPanelModal #admin-tab-tasks.active {
    padding-bottom: 24px;
}

#adminPanelModal #admin-tab-tasks .admin-json-block {
    max-height: none;
    overflow: visible;
}

.admin-content {
    flex: 1;
    min-height: 0;
    padding: 24px;
    overflow-y: auto;
    background: var(--preview-bg);
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
}

.admin-tab-content h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    border: 1px solid var(--border);
    transition: all 0.2s ease;
}

.admin-stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

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

.stat-icon.users { background: linear-gradient(135deg, #0071e3 0%, #2997ff 100%); color: white; }
.stat-icon.active { background: linear-gradient(135deg, #10b981 0%, #34d399 100%); color: white; }
.stat-icon.new { background: linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%); color: white; }
.stat-icon.revenue { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); color: white; }

.stat-info {
    height: 100%;
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.admin-detail-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.admin-detail-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
}

.admin-detail-card h4 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.membership-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.membership-bar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.membership-bar .label {
    width: 40px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.membership-bar .bar {
    height: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.membership-bar .fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.membership-bar .fill.free { background: linear-gradient(90deg, #94a3b8, #cbd5e1); }
.membership-bar .fill.pro { background: linear-gradient(90deg, #0071e3, #2997ff); }
.membership-bar .fill.max { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.membership-bar .fill.ultra { background: linear-gradient(90deg, #7c3aed, #a855f7); }

.membership-bar .count {
    width: 40px;
    text-align: right;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.usage-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.usage-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.usage-row:last-child {
    border-bottom: none;
}

.usage-row span:first-child {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.usage-row span:last-child {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.admin-toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.admin-toolbar input,
.admin-toolbar select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
}

.admin-toolbar input {
    min-width: 200px;
}

.admin-toolbar label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

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

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

.admin-table th,
.admin-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.admin-table th {
    background: rgba(0, 113, 227, 0.05);
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table td {
    font-size: 0.9rem;
    color: var(--text-primary);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.admin-table tr:hover {
    background: rgba(0, 113, 227, 0.03);
}

.membership-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.membership-badge.free { background: #e2e8f0; color: #475569; }
.membership-badge.pro { background: linear-gradient(135deg, #0071e3 0%, #2997ff 100%); color: white; }
.membership-badge.max { background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%); color: white; }
.membership-badge.ultra { background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%); color: white; }
.membership-badge.admin { background: linear-gradient(135deg, #ef4444 0%, #f87171 100%); color: white; }
.membership-badge.disabled { background: #fee2e2; color: #dc2626; }

.action-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-right: 6px;
}

.action-btn.view { background: #e0e7ff; color: #4f46e5; }
.action-btn.view:hover { background: #c7d2fe; }

.action-btn.edit { background: #d1fae5; color: #059669; }
.action-btn.edit:hover { background: #a7f3d0; }

.action-btn.disable { background: #fee2e2; color: #dc2626; }
.action-btn.disable:hover { background: #fecaca; }

.action-btn.enable { background: #d1fae5; color: #059669; }
.action-btn.enable:hover { background: #a7f3d0; }

.admin-pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.admin-pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-pagination button:hover {
    background: rgba(0, 113, 227, 0.1);
    border-color: var(--primary);
    color: var(--primary);
}

.admin-pagination button.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.admin-pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ip-abuse-card {
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border);
    margin-bottom: 16px;
    overflow: hidden;
}

.ip-abuse-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: rgba(239, 68, 68, 0.05);
    border-bottom: 1px solid var(--border);
}

.ip-abuse-header .ip-address {
    font-family: monospace;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.ip-abuse-header .user-count {
    background: #fee2e2;
    color: #dc2626;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
}

.ip-abuse-users {
    padding: 12px 20px;
}

.ip-user-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.ip-user-item:last-child {
    border-bottom: none;
}

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

.ip-user-name {
    font-weight: 500;
    color: var(--text-primary);
}

.ip-user-email {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.ip-user-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.user-detail-section {
    margin-bottom: 20px;
}

.user-detail-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.user-detail-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
}

.user-detail-row .label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.user-detail-row .value {
    font-weight: 500;
    color: var(--text-primary);
}

.user-action-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.membership-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .admin-sidebar {
        width: 60px;
        padding: 12px 4px;
    }

    .admin-nav-btn span {
        display: none;
    }

    .admin-nav-btn {
        justify-content: center;
        padding: 12px;
    }

    .admin-stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .admin-detail-cards {
        grid-template-columns: 1fr;
    }
}
