/* 购买记录工作区壳兼容样式 */
#purchaseHistoryPage.aff-page-shell {
    max-width: none;
    margin: 0;
}

.aff-hero-card-history {
    min-height: 240px;
}

#purchaseHistoryPage .aff-hero-card-history .aff-kicker {
    padding: 5px 10px;
    font-size: 0.64rem;
    letter-spacing: 0.14em;
}

#purchaseHistoryPage .aff-hero-card-history .aff-hero-copy h2 {
    margin: 4px 0 8px;
    font-size: clamp(1.28rem, 2vw, 2rem);
    line-height: 1.08;
}

#purchaseHistoryPage .aff-hero-card-history .aff-hero-copy p {
    max-width: 620px;
    font-size: 0.8rem;
    line-height: 1.52;
}

#purchaseHistoryPage .aff-hero-card-history .aff-note-card {
    padding: 12px 14px;
    border-radius: 16px;
}

#purchaseHistoryPage .aff-hero-card-history .aff-note-title {
    margin-bottom: 6px;
    font-size: 0.72rem;
    letter-spacing: 0.12em;
}

#purchaseHistoryPage .aff-hero-card-history .aff-note-list {
    font-size: 0.76rem;
    line-height: 1.52;
}

#purchaseHistoryPage .aff-hero-card-history {
    grid-template-columns: minmax(0, 1.55fr) minmax(220px, 0.72fr);
    gap: 14px;
    padding: 20px 22px;
    border-radius: 24px;
    min-height: 0;
}

#purchaseHistoryPage .aff-hero-card-history::after {
    width: 180px;
    height: 180px;
    inset: auto -4% -16% auto;
}

#purchaseHistoryPage .page-header.aff-section-head {
    align-items: flex-start;
}

.aff-history-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: flex-end;
}

.aff-history-summary-chip {
    display: inline-flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 999px;
    background: rgba(255, 244, 225, 0.9);
    border: 1px solid rgba(229, 196, 142, 0.52);
    color: #6c4c27;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

#purchaseHistoryPage .payment-return-banner {
    margin: 0 0 18px;
}

#purchaseHistoryPage .aff-table-wrap {
    margin-top: 0;
    padding: 0;
    overflow: auto;
    border-radius: 20px;
    border: 1px solid rgba(216, 190, 150, 0.45);
    background: rgba(255, 255, 255, 0.72);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55);
}

#purchaseHistoryPage #purchaseHistoryTable {
    width: 100%;
    min-width: 1080px;
}

#purchaseHistoryPage #purchaseHistoryTable th {
    background: rgba(255, 245, 228, 0.95);
    color: #4d3520;
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(216, 190, 150, 0.45);
}

#purchaseHistoryPage #purchaseHistoryTable td {
    background: rgba(255, 255, 255, 0.66);
    border-bottom: 1px solid rgba(236, 224, 206, 0.7);
}

#purchaseHistoryPage #purchaseHistoryTable tbody tr:hover {
    background: rgba(255, 247, 233, 0.7);
}

#purchaseHistoryPage #purchaseHistoryTable tbody tr:hover td {
    background: rgba(255, 247, 233, 0.78);
}

#purchaseHistoryPage .order-no-cell .order-no {
    font-family: var(--font-mono);
    background: rgba(255, 245, 228, 0.92);
    color: #6d4f2d;
    border-radius: 999px;
    padding: 6px 10px;
}

#purchaseHistoryPage .amount-cell {
    color: #c65d14;
}

#purchaseHistoryPage .status-badge {
    border: 1px solid transparent;
}

#purchaseHistoryPage .status-success {
    background: rgba(16, 185, 129, 0.12);
    border-color: rgba(16, 185, 129, 0.24);
}

#purchaseHistoryPage .status-warning {
    background: rgba(245, 158, 11, 0.12);
    border-color: rgba(245, 158, 11, 0.24);
}

#purchaseHistoryPage .status-error {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.22);
}

#purchaseHistoryPage .page-btn {
    border: none;
    border-radius: 999px;
    padding: 11px 18px;
    background: linear-gradient(135deg, #fff2da, #ffd89b);
    color: #4c3420;
    font-weight: 700;
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    box-shadow: 0 10px 24px rgba(167, 108, 21, 0.12);
}

#purchaseHistoryPage .page-btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

#purchaseHistoryPage .page-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
}

#purchaseHistoryPage .aff-pagination {
    margin-top: 18px;
    justify-content: flex-end;
    gap: 12px;
}

#purchaseHistoryPage .page-info {
    color: var(--color-text-secondary);
    font-size: 0.88rem;
}

#purchaseHistoryPage #purchaseAiUsageTable {
    width: 100%;
    min-width: 860px;
}

#purchaseHistoryPage #purchaseAiUsageTable th {
    background: rgba(241, 244, 255, 0.95);
    color: #354b76;
    font-family: var(--font-display);
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(180, 195, 228, 0.45);
}

#purchaseHistoryPage #purchaseAiUsageTable td {
    background: rgba(250, 252, 255, 0.72);
    border-bottom: 1px solid rgba(220, 228, 242, 0.7);
}

#purchaseHistoryPage #purchaseAiUsageTable tbody tr:hover {
    background: rgba(241, 246, 255, 0.74);
}

#purchaseHistoryPage #purchaseAiUsageTable tbody tr:hover td {
    background: rgba(241, 246, 255, 0.82);
}

#purchaseHistoryPage #purchaseAiUsageTable .amount-cell {
    color: #9a3412;
    font-weight: 800;
}

@media (max-width: 980px) {
.aff-history-summary {
        justify-content: flex-start;
    }

#purchaseHistoryPage .aff-hero-card-history {
        grid-template-columns: 1fr;
        padding: 18px;
    }
}

@media (max-width: 768px) {
#purchaseHistoryPage .page-header.aff-section-head {
        flex-direction: column;
        align-items: flex-start;
    }

#purchaseHistoryPage .aff-pagination {
        justify-content: flex-start;
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
#purchaseHistoryPage .aff-history-summary {
        gap: 8px;
    }

#purchaseHistoryPage .aff-history-summary-chip {
        font-size: 0.7rem;
    }
}

[data-theme="dark"] #purchaseHistoryPage .aff-table-wrap,
[data-theme="dark"] #purchaseHistoryPage #purchaseHistoryTable td {
    background: rgba(27, 35, 49, 0.82);
    border-color: rgba(96, 114, 138, 0.45);
}

[data-theme="dark"] #purchaseHistoryPage #purchaseHistoryTable th {
    background: rgba(37, 48, 66, 0.92);
    color: #f8e4bc;
    border-bottom-color: rgba(96, 114, 138, 0.42);
}

[data-theme="dark"] #purchaseHistoryPage #purchaseHistoryTable tbody tr:hover td {
    background: rgba(37, 48, 66, 0.96);
}

[data-theme="dark"] #purchaseHistoryPage .order-no-cell .order-no,
[data-theme="dark"] .aff-history-summary-chip {
    background: rgba(54, 69, 94, 0.8);
    color: #f7d6a0;
    border-color: rgba(117, 135, 159, 0.42);
}

[data-theme="dark"] #purchaseHistoryPage .page-btn {
    background: linear-gradient(135deg, rgba(70, 85, 111, 0.92), rgba(46, 58, 79, 0.92));
    color: #f3dcc0;
}

[data-theme="dark"] #purchaseHistoryPage .page-info {
    color: #94a3b8;
}

/* ==================== 购买记录页面样式 ==================== */

#purchaseHistoryPage .payment-return-banner {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 16px 20px;
    margin: 0 0 20px;
    border-radius: 18px;
    background: rgba(255, 248, 238, 0.88);
    border: 1px solid rgba(228, 196, 148, 0.55);
    animation: licFadeIn 0.3s ease;
}

#purchaseHistoryPage .payment-return-banner.prb-success {
    background: rgba(209, 250, 229, 0.7);
    border-color: rgba(16, 185, 129, 0.3);
}

#purchaseHistoryPage .payment-return-banner.prb-timeout {
    background: rgba(254, 243, 199, 0.7);
    border-color: rgba(245, 158, 11, 0.3);
}

#purchaseHistoryPage .prb-icon {
    flex-shrink: 0;
    font-size: 1.6rem;
    line-height: 1;
    color: var(--color-primary);
}

#purchaseHistoryPage .prb-icon-warning {
    color: var(--color-warning);
}

#purchaseHistoryPage .prb-icon-success {
    color: var(--color-success);
}

#purchaseHistoryPage .prb-text strong {
    display: block;
    margin-bottom: 4px;
    font-size: 0.94rem;
    color: #202534;
}

#purchaseHistoryPage .prb-text p {
    margin: 0;
    font-size: 0.84rem;
    color: var(--color-text-secondary);
    line-height: 1.6;
}

#purchaseHistoryPage {
    padding: 20px;
}

#purchaseHistoryTable {
    width: 100%;
}

#purchaseHistoryTable th {
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: white;
    font-weight: 600;
    padding: 14px 12px;
    font-size: 14px;
    white-space: nowrap;
}

#purchaseHistoryTable td {
    padding: 14px 12px;
    font-size: 14px;
    vertical-align: middle;
}

#purchaseHistoryTable tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

/* 订单号单元格 */
#purchaseHistoryPage .order-no-cell .order-no {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    color: #64748b;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
}

/* 金额单元格 */
#purchaseHistoryPage .amount-cell {
    font-weight: 600;
    color: #ef4444;
}

/* 时间单元格 */
#purchaseHistoryPage .time-cell {
    font-size: 13px;
    color: #64748b;
    white-space: nowrap;
}

/* 状态徽章 */
#purchaseHistoryPage .status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

#purchaseHistoryPage .status-success {
    background: rgba(34, 197, 94, 0.12);
    color: #16a34a;
}

#purchaseHistoryPage .status-warning {
    background: rgba(245, 158, 11, 0.12);
    color: #d97706;
}

#purchaseHistoryPage .status-error {
    background: rgba(239, 68, 68, 0.12);
    color: #dc2626;
}

/* 卡密单元格 */
#purchaseHistoryPage .license-cell {
    min-width: 180px;
}

/* 状态/操作列 */
#purchaseHistoryPage .status-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

#purchaseHistoryPage .status-sub {
    font-size: 12px;
    color: #64748b;
    white-space: nowrap;
}

#purchaseHistoryPage .status-sub--expired {
    color: #dc2626;
    font-weight: 600;
}

#purchaseHistoryPage .action-cell {
    white-space: nowrap;
}

#purchaseHistoryPage .action-muted {
    color: #94a3b8;
}

#purchaseHistoryPage .btn-action {
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 700;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

#purchaseHistoryPage .btn-action-primary {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.35);
    color: #16a34a;
}

#purchaseHistoryPage .btn-action-primary:hover {
    background: rgba(34, 197, 94, 0.2);
}

#purchaseHistoryPage .btn-action-secondary {
    background: rgba(99, 102, 241, 0.08);
    border-color: rgba(99, 102, 241, 0.25);
    color: #6366f1;
}

#purchaseHistoryPage .btn-action-secondary:hover {
    background: rgba(99, 102, 241, 0.16);
}

#purchaseHistoryPage .no-license {
    color: #94a3b8;
}

#purchaseHistoryPage .license-code-display {
    display: flex;
    align-items: center;
    gap: 8px;
}

#purchaseHistoryPage .license-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 12px;
    color: #0f172a;
    background: #f1f5f9;
    padding: 4px 8px;
    border-radius: 4px;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#purchaseHistoryPage .btn-copy-sm {
    padding: 4px 8px;
    font-size: 12px;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

#purchaseHistoryPage .btn-copy-sm:hover {
    opacity: 1;
}

#purchaseHistoryPage .license-codes-multi .btn-view-codes {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid #6366f1;
    border-radius: 6px;
    background: rgba(99, 102, 241, 0.08);
    color: #6366f1;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

#purchaseHistoryPage .license-codes-multi .btn-view-codes:hover {
    background: #6366f1;
    color: white;
}

/* 加载/空/错误状态 */
#purchaseHistoryPage .loading-cell,
#purchaseHistoryPage .empty-cell,
#purchaseHistoryPage .error-cell {
    text-align: center;
    padding: 48px 24px !important;
}

#purchaseHistoryPage .loading-cell {
    color: #64748b;
}

#purchaseHistoryPage .loading-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid #e2e8f0;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 12px;
    vertical-align: middle;
}

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

#purchaseHistoryPage .empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

#purchaseHistoryPage .empty-icon {
    font-size: 48px;
}

#purchaseHistoryPage .empty-state p {
    color: #64748b;
    font-size: 14px;
}

#purchaseHistoryPage .empty-link {
    color: #6366f1;
    text-decoration: none;
    font-weight: 600;
}

#purchaseHistoryPage .empty-link:hover {
    text-decoration: underline;
}

#purchaseHistoryPage .error-cell {
    color: #ef4444;
}

/* 购买记录分页 */
#purchaseHistoryPagination {
    margin-top: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

#purchaseHistoryPagination .page-btn {
    padding: 10px 20px;
}

#purchaseHistoryPagination .page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* 卡密弹窗 */
#licenseCodesModal .license-codes-list {
    max-height: 300px;
    overflow-y: auto;
    margin: 16px 0;
}

#licenseCodesModal .license-code-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

#licenseCodesModal .code-index {
    font-weight: 600;
    color: #64748b;
    min-width: 24px;
}

#licenseCodesModal .license-code {
    flex: 1;
    max-width: none;
}
