/* 后台管理系统样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    color: #1f2329;
    line-height: 1.6;
}

.admin-container {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.admin-sidebar {
    width: 240px;
    background: #1f2329;
    color: #fff;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.admin-logo {
    padding: 24px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.admin-logo .logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #c62828, #8e0000);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
}

.admin-logo .logo-text h1 {
    font-size: 16px;
    font-weight: 600;
}

.admin-logo .logo-text p {
    font-size: 12px;
    color: rgba(255,255,255,0.6);
}

.admin-nav {
    flex: 1;
    padding: 16px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-item.active {
    background: rgba(198, 40, 40, 0.2);
    color: #ff5252;
    border-left: 3px solid #ff5252;
}

.nav-icon {
    font-size: 18px;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 8px 20px;
}

/* 导航分组 */
.nav-group {
    margin-top: 4px;
}

.nav-group-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 20px;
    font-size: 11px;
    font-weight: 600;
    color: rgba(255,255,255,0.35);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.nav-group-title:hover {
    color: rgba(255,255,255,0.6);
}

.nav-group-arrow {
    font-size: 10px;
    transition: transform 0.2s;
}

.nav-group.collapsed .nav-group-arrow {
    transform: rotate(-90deg);
}

.nav-group.collapsed .nav-group-items {
    display: none;
}

.nav-group-items {
    display: block;
}

.nav-group-items .nav-item {
    padding-left: 36px;
    font-size: 13px;
}

.nav-group-items .nav-icon {
    font-size: 15px;
}

.admin-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.back-to-front {
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.back-to-front:hover {
    color: #fff;
}

/* 主内容区 */
.admin-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
}

.admin-header {
    background: #fff;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #e5e6eb;
    position: sticky;
    top: 0;
    z-index: 100;
}

.admin-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.admin-user {
    font-size: 14px;
    color: #646a73;
}

/* 页面内容 */
.admin-page {
    display: none;
    padding: 24px 32px;
    flex: 1;
}

.admin-page.active {
    display: block;
}

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

.stat-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.stat-icon {
    width: 48px;
    height: 48px;
    background: #f0f1f5;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-info h3 {
    font-size: 28px;
    font-weight: 600;
    color: #1f2329;
}

.stat-info p {
    font-size: 14px;
    color: #646a73;
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* 统计卡片行 */
.stat-cards {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}
.stat-cards .stat-card {
    flex: 1;
    min-width: 120px;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 16px;
}
.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
}

/* 卡片 */
.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.recent-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: #f7f8fa;
    border-radius: 8px;
}

.recent-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.recent-item-icon {
    width: 36px;
    height: 36px;
    background: #fff;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

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

.recent-item-code {
    font-size: 12px;
    color: #646a73;
}

.recent-item-time {
    font-size: 12px;
    color: #646a73;
}

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

.search-box {
    display: flex;
    gap: 8px;
}

.search-box input {
    padding: 8px 16px;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    font-size: 14px;
    width: 280px;
}

.search-box input:focus {
    outline: none;
    border-color: #c62828;
}

.btn-primary {
    padding: 8px 20px;
    background: #c62828;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-primary:hover {
    background: #8e0000;
}

.btn-secondary {
    padding: 8px 20px;
    background: #f0f1f5;
    color: #1f2329;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #e5e6eb;
}

/* 表格 */
.table-container {
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

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

.data-table th,
.data-table td {
    padding: 12px 16px;
    text-align: left;
    font-size: 14px;
}

.data-table th {
    background: #f7f8fa;
    font-weight: 600;
    color: #646a73;
}

.data-table tr {
    border-bottom: 1px solid #f0f1f5;
}

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

.data-table tr:hover {
    background: #f7f8fa;
}

.status-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.status-pending {
    background: #fff3e0;
    color: #ef6c00;
}

.status-appraised {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-stored {
    background: #e3f2fd;
    color: #1565c0;
}

.status-sold {
    background: #f3e5f5;
    color: #6a1b9a;
}

.action-btn {
    padding: 4px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin-right: 4px;
}

.action-btn.view {
    background: #e3f2fd;
    color: #1565c0;
}

.action-btn.delete {
    background: #ffebee;
    color: #c62828;
}

.action-btn:hover {
    opacity: 0.8;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #e5e6eb;
    background: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.pagination button:hover {
    border-color: #c62828;
    color: #c62828;
}

.pagination button.active {
    background: #c62828;
    color: #fff;
    border-color: #c62828;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.modal-large {
    max-width: 700px;
}

.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e5e6eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 16px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #646a73;
}

.modal-body {
    padding: 20px;
}

/* 表单 */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #1f2329;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e6eb;
    border-radius: 8px;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #c62828;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
}

/* 溯源详情 */
.trace-detail {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.trace-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.trace-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.trace-info-label {
    font-size: 12px;
    color: #646a73;
}

.trace-info-value {
    font-size: 14px;
    font-weight: 500;
}

.trace-timeline {
    margin-top: 20px;
}

.trace-timeline h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.timeline-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.timeline-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: #f7f8fa;
    border-radius: 8px;
}

.timeline-icon {
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.timeline-content {
    flex: 1;
}

.timeline-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
}

.timeline-desc {
    font-size: 12px;
    color: #646a73;
}

.timeline-time {
    font-size: 12px;
    color: #646a73;
    margin-top: 4px;
}

/* 响应式 */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        bottom: 0;
        width: 260px;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: none;
    }
    
    .admin-sidebar.open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }
    
    .admin-main {
        margin-left: 0;
        padding: 16px;
    }
    
    .mobile-menu-btn {
        display: flex !important;
    }
    
    .admin-logo .logo-text,
    .nav-item span:not(.nav-icon),
    .admin-footer,
    .nav-group-title span:first-child {
        display: inline;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .admin-table {
        min-width: 600px;
    }
    
    .modal-content {
        width: 95%;
        margin: 20px auto;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    #trendChart {
        height: 200px !important;
    }
    
    #page-analytics > div[style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 999;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e5e6eb;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
}

.sidebar-overlay.show {
    display: block;
}

/* 搜索和筛选 */
.search-input,
.filter-select {
    padding: 8px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    outline: none;
    transition: border-color 0.2s;
}

.search-input:focus,
.filter-select:focus {
    border-color: #c62828;
}

.search-input {
    min-width: 240px;
}

/* 表单输入 */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-input:focus {
    border-color: #c62828;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
    line-height: 1.5;
}

.badge-active, .badge-approved {
    background: #dcfce7;
    color: #166534;
}

.badge-disabled, .badge-rejected {
    background: #fee2e2;
    color: #991b1b;
}

.badge-pending {
    background: #fef3c7;
    color: #92400e;
}

.badge-admin {
    background: #ede9fe;
    color: #5b21b6;
}

.badge-user {
    background: #e0f2fe;
    color: #075985;
}

.badge-high {
    background: #fee2e2;
    color: #991b1b;
}

.badge-medium {
    background: #fef3c7;
    color: #92400e;
}

.badge-low {
    background: #dcfce7;
    color: #166534;
}

.badge-paid {
    background: #dcfce7;
    color: #166534;
}

.badge-cancelled {
    background: #f3f4f6;
    color: #6b7280;
}

/* 提示框 */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin: 10px 0;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.alert-danger {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

/* 按钮变体 */
.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-success:hover {
    background: #15803d;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-secondary {
    background: #6b7280;
    color: #fff;
}

.btn-secondary:hover {
    background: #4b5563;
}

/* 标签页 */
.tab-btn {
    padding: 8px 20px;
    border: none;
    background: transparent;
    color: #6b7280;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-btn.active {
    color: #c62828;
    border-bottom-color: #c62828;
}

.tab-btn:hover {
    color: #c62828;
}

.billing-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 20px;
}

.billing-section {
    display: none;
}

.billing-section.active {
    display: block;
}

/* 空状态 */
.empty {
    text-align: center;
    color: #9ca3af;
    padding: 40px 0;
}

/* 信息列表 */
.info-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
}

.info-item span:first-child {
    color: #6b7280;
}

.info-item span:last-child {
    font-weight: 500;
}
