:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-900: #111827;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
}

/* 布局 */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 240px;
    background: var(--gray-900);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.sidebar-nav {
    padding: 16px 0;
}

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

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

.nav-item.active {
    background: var(--primary);
    color: white;
}

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

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 30px;
}

/* 提示消息 */
.alerts {
    margin-bottom: 24px;
}

.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid var(--success);
}

.alert-info {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    border: 1px solid var(--primary);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid var(--danger);
}

/* 页面标题 */
.page-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 24px;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.page-header .page-title {
    margin-bottom: 0;
}

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

.stat-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stat-icon {
    width: 50px;
    height: 50px;
    background: var(--gray-100);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-profit .stat-icon {
    background: rgba(16, 185, 129, 0.1);
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
}

.stat-label {
    color: var(--gray-500);
    font-size: 14px;
}

/* Dashboard行 */
.dashboard-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.dashboard-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.dashboard-card h3 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

/* 状态列表 */
.status-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-dot.pending { background: var(--warning); }
.status-dot.processing { background: var(--primary); }
.status-dot.completed { background: var(--success); }
.status-dot.failed { background: var(--danger); }

.status-count {
    margin-left: auto;
    font-weight: 600;
}

/* 快速操作 */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--gray-100);
    border-radius: 8px;
    text-decoration: none;
    color: var(--gray-700);
    transition: all 0.3s;
}

.action-btn:hover {
    background: var(--primary);
    color: white;
}

/* 数据表格 */
.data-table {
    width: 100%;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.data-table th,
.data-table td {
    padding: 14px 20px;
    text-align: left;
}

.data-table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.data-table td {
    border-bottom: 1px solid var(--gray-100);
}

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

.data-table a {
    color: var(--primary);
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

.data-table .price {
    color: var(--danger);
    font-weight: 600;
}

.data-table .profit {
    color: var(--success);
    font-weight: 600;
}

.data-table .empty {
    text-align: center;
    padding: 40px;
    color: var(--gray-500);
}

.text-muted {
    color: var(--gray-500);
    font-size: 12px;
}

/* 徽章 */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.badge.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.badge.danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

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

.status-badge.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.status-badge.processing {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.status-badge.completed,
.status-badge.delivered {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.status-badge.failed,
.status-badge.unpaid {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

/* 操作链接 */
.action-link {
    color: var(--primary);
    text-decoration: none;
    margin-right: 12px;
    font-size: 14px;
}

.action-link.danger {
    color: var(--danger);
}

.action-link:hover {
    text-decoration: underline;
}

/* 表单卡片 */
.form-card {
    background: white;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.form-card h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.form-hint {
    color: var(--gray-500);
    font-size: 14px;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--gray-700);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--gray-500);
    font-size: 12px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.checkbox-label input {
    width: auto;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* 按钮 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.3s;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
}

/* 详情网格 */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.detail-card {
    background: white;
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.detail-card.full-width {
    grid-column: span 3;
}

.detail-card h3 {
    font-size: 16px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.detail-row .label {
    color: var(--gray-500);
}

.detail-row .value {
    font-weight: 500;
}

.detail-row .price {
    color: var(--danger);
}

.detail-row .profit {
    color: var(--success);
}

.card-key-display {
    background: var(--gray-900);
    padding: 16px;
    border-radius: 8px;
    margin-top: 12px;
}

.card-key-display code {
    color: var(--success);
    font-family: monospace;
    word-break: break-all;
}

.deliver-form {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.deliver-form input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
}

.empty {
    color: var(--gray-500);
    font-style: italic;
}

/* 测试结果 */
.test-result {
    margin-top: 16px;
    padding: 16px;
    border-radius: 8px;
    display: none;
}

.test-result.show {
    display: block;
}

.test-result.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.test-result.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

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

.page-link {
    padding: 8px 14px;
    background: white;
    border-radius: 6px;
    text-decoration: none;
    color: var(--gray-700);
    font-size: 14px;
}

.page-link:hover {
    background: var(--gray-100);
}

.page-link.active {
    background: var(--primary);
    color: white;
}

/* 筛选框 */
.filter-box {
    display: flex;
    align-items: center;
}

.filter-form {
    display: flex;
    gap: 12px;
    align-items: center;
}

.filter-form select {
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
}

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

@media (max-width: 768px) {
    .sidebar {
        width: 60px;
    }
    
    .sidebar-header h2,
    .sidebar-nav .nav-item span {
        display: none;
    }
    
    .main-content {
        margin-left: 60px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    
    .detail-grid {
        grid-template-columns: 1fr;
    }
    
    .detail-card.full-width {
        grid-column: span 1;
    }
}

/* ─── 商品导入页面 ─────────────────────────────────── */
.page-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.stats-mini {
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    gap: 16px;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.stats-mini .separator {
    color: var(--gray-300);
}

.stats-mini .text-success { color: var(--success); font-weight: 600; }
.stats-mini .text-muted { color: var(--gray-500); font-weight: 600; }

.filter-bar {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.filter-bar .input {
    padding: 8px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
}

.filter-bar .input:focus {
    border-color: var(--primary);
    outline: none;
}

.filter-bar .checkbox-label {
    margin-left: auto;
}

.filter-info {
    font-size: 13px;
    color: var(--gray-500);
}

.filter-info strong {
    color: var(--primary);
}

.batch-settings {
    background: #fff3e0;
    border: 1px solid #ffcc80;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 14px;
    flex-wrap: wrap;
}

.batch-settings .input-small {
    width: 80px;
    padding: 6px 10px;
    border: 2px solid var(--gray-200);
    border-radius: 6px;
    font-size: 14px;
    text-align: center;
}

.batch-hint {
    color: #e65100;
    font-size: 12px;
}

.btn-small {
    padding: 6px 14px;
    font-size: 13px;
}

/* 加载状态 */
.loading-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-state p {
    color: var(--gray-500);
    margin-bottom: 8px;
}

.loading-hint {
    font-size: 12px;
    color: var(--gray-300);
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: var(--gray-500);
}

/* 导入结果 */
.import-result {
    margin-top: 20px;
}

.import-result .alert {
    padding: 16px 20px;
    border-radius: 8px;
    font-size: 15px;
}

/* 商品卡片网格 */
.import-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.import-card {
    background: white;
    border-radius: 10px;
    border: 2px solid var(--gray-200);
    overflow: hidden;
    transition: all 0.2s;
}

.import-card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.15);
}

.import-card.selected {
    border-color: var(--primary);
    background: rgba(99, 102, 241, 0.03);
}

.import-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--gray-200);
}

.category-tag {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.stock-tag {
    margin-left: auto;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
}

.stock-tag.stock-ok {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.stock-tag.stock-low {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.stock-tag.stock-out {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.import-card-body {
    padding: 16px;
}

.product-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 8px;
    color: var(--gray-900);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.product-desc {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
    line-height: 1.4;
}

.price-row {
    display: flex;
    gap: 16px;
    align-items: center;
}

.price-item {
    flex: 1;
}

.price-item label {
    display: block;
    font-size: 11px;
    color: var(--gray-500);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cost-price {
    font-size: 16px;
    font-weight: 700;
    color: var(--gray-700);
}

.sell-price-input {
    width: 100%;
    padding: 6px 10px;
    border: 2px solid var(--success);
    border-radius: 6px;
    font-size: 15px;
    font-weight: 600;
    color: var(--success);
    background: rgba(16, 185, 129, 0.05);
}

.sell-price-input:focus {
    outline: none;
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.1);
}

.sell-price-input[readonly] {
    background: var(--gray-100);
    border-color: var(--gray-200);
    color: var(--gray-500);
}

.product-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.meta-tag {
    font-size: 11px;
    color: var(--gray-500);
    background: var(--gray-100);
    padding: 2px 8px;
    border-radius: 4px;
}

/* 商品管理页库存样式 */
.stock-ok { color: var(--success); font-weight: 600; }
.stock-low { color: var(--warning); font-weight: 600; }
.stock-zero { color: var(--danger); font-weight: 600; }

/* 下架行样式 */
.row-inactive {
    opacity: 0.5;
    background: var(--gray-100);
}

.row-inactive:hover {
    opacity: 0.7;
}

.badge.inactive {
    background: var(--gray-200);
    color: var(--gray-500);
}

.text-small {
    font-size: 11px;
}

.inline {
    display: inline;
}

.action-link.success {
    color: var(--success);
}

/* 测试结果增强样式 */
.loading-dots span {
    animation: dot-blink 1.4s infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-blink {
    0%, 80%, 100% { opacity: 0; }
    40% { opacity: 1; }
}

.result-table {
    margin-top: 12px;
}

.result-row {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
}

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

.result-label {
    color: var(--gray-500);
    min-width: 80px;
}

.result-value {
    font-weight: 600;
}

.result-value.money {
    color: var(--success);
    font-size: 16px;
}

.success-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.error-header {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
}

.error-message {
    color: var(--danger);
    font-size: 14px;
}

.error-hint {
    margin-top: 8px;
    font-size: 13px;
    color: var(--gray-500);
}

.error-detail {
    margin-top: 8px;
    font-size: 12px;
    color: var(--gray-500);
    word-break: break-all;
    background: var(--gray-100);
    padding: 8px;
    border-radius: 6px;
}
