/* ========================================
   订单号 OCR 工具 - 现代质感 SaaS 风格
   ======================================== */

:root {
    /* 基础色彩 */
    --bg-body: #f8fafc; 
    --bg-card: rgba(255, 255, 255, 0.95); /* 卡片带一点点透明，透出极微弱背景色 */
    --border-color: #e2e8f0;
    --border-focus: #3b82f6;
    
    /* 文本颜色 */
    --text-main: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* 强调色 */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --success: #10b981;
    --success-hover: #059669;
    --warning: #f59e0b;
    --warning-hover: #d97706;
    --danger: #ef4444;
    --danger-hover: #dc2626;

    /* 尺寸与阴影 */
    --radius-md: 8px;
    --radius-lg: 12px;
    /* 卡片的阴影加深了一点，以便在有色背景上“浮”起来 */
    --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);

    --transition: all 0.2s ease-in-out;
}

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

/* ========================================
   背景与主布局（核心视觉提升）
   ======================================== */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
    background-color: var(--bg-body);
    /* 关键点：左上角蓝色光晕，右下角紫色光晕，打破单调 */
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.08) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.08) 0px, transparent 50%);
    background-attachment: fixed;
}

/* --- 滚动条全局优化 --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* --- 遮罩与加载 --- */
.loading-mask {
    position: fixed; inset: 0; z-index: 9999;
    background: #ffffff;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    transition: opacity .3s;
}
.loading-mask.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loading-spinner {
    width: 32px; height: 32px; border: 3px solid #e2e8f0; border-top-color: var(--primary);
    border-radius: 50%; animation: spin .8s linear infinite;
}
.loading-mask p { margin-top: 16px; color: var(--text-secondary); font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 顶部导航（毛玻璃效果） --- */
.app-header {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    height: 60px;
    padding: 0 24px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 100;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { font-size: 22px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1)); }
.logo-text h1 { font-size: 16px; font-weight: 700; color: var(--text-main); letter-spacing: 0.5px; }

.header-right { display: flex; align-items: center; gap: 16px; }
.connection-status { 
    display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary);
    background: #f1f5f9; padding: 6px 12px; border-radius: 20px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-muted); }
.status-dot.online { background: var(--success); box-shadow: 0 0 0 3px rgba(16,185,129,0.15); }

.btn-icon {
    width: 34px; height: 34px; display: flex; align-items: center; justify-content: center;
    background: #ffffff; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    color: var(--text-secondary); cursor: pointer; transition: var(--transition);
    box-shadow: var(--shadow-sm);
}
.btn-icon:hover { background: #f8fafc; color: var(--text-main); transform: rotate(15deg); }

/* --- 统计栏 --- */
.summary-bar {
    background: transparent; 
    padding: 16px 24px;
    display: flex; justify-content: space-between; align-items: center;
    flex-shrink: 0;
}
.summary-group { display: flex; align-items: center; gap: 40px; }
.summary-item { display: flex; flex-direction: column; gap: 4px; }
.summary-item.align-right { align-items: flex-end; }
.summary-label { font-size: 12.5px; color: var(--text-secondary); font-weight: 600; }
.summary-value { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; }
.text-blue { color: var(--primary); }
.text-green { color: var(--success); }
.text-orange { color: var(--warning); }
.text-red { color: var(--danger); }

/* --- 主布局 --- */
.main-content {
    flex: 1; display: flex; gap: 20px; padding: 0 24px 24px 24px;
    overflow: hidden; min-height: 0;
}

/* --- 左侧操作面板 (解决截断问题的核心) --- */
.operation-panel {
    width: 330px; flex-shrink: 0;
    display: flex; flex-direction: column;
    overflow-y: auto; 
    overflow-x: hidden;
    padding-right: 4px; /* 留出滚动条空间 */
}
.panel-scroll-inner {
    display: flex; flex-direction: column; gap: 16px; padding-bottom: 20px;
}

/* --- 卡片通用样式 (增加悬浮质感) --- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    padding: 16px 18px; border-bottom: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 10px;
    background: rgba(248, 250, 252, 0.5);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.card-header h3 { font-size: 14.5px; font-weight: 700; color: var(--text-main); }
.step-num {
    width: 24px; height: 24px; border-radius: 6px;
    background: #eff6ff; color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 800; flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.2);
}
.card-body { padding: 18px; display: flex; flex-direction: column; }

/* --- 表单与输入框 --- */
.form-group { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.form-group:last-child { margin-bottom: 0; }
.form-group label { font-size: 13px; font-weight: 600; color: var(--text-secondary); }
.form-input {
    width: 100%; padding: 10px 12px; font-size: 13.5px; color: var(--text-main);
    border: 1px solid #cbd5e1; border-radius: var(--radius-md);
    background: #ffffff; outline: none; transition: var(--transition);
    min-height: 38px;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.02);
}
.form-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }
.form-input:disabled { background: #f1f5f9; cursor: not-allowed; color: var(--text-muted); box-shadow: none; }

.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); cursor: pointer; }
.checkbox-text { font-size: 13.5px; color: var(--text-main); }

/* --- 按钮体系 (加入微妙渐变) --- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 9px 16px; border: 1px solid transparent; border-radius: var(--radius-md);
    font-size: 13.5px; font-weight: 600; cursor: pointer;
    transition: var(--transition); white-space: nowrap;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.btn:active:not(:disabled) { transform: scale(0.98); box-shadow: none; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; box-shadow: none; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 16px; font-size: 14.5px; }
.mt-2 { margin-top: 10px; }
.mt-3 { margin-top: 14px; }
.mt-4 { margin-top: 20px; }

.btn-primary { background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%); color: #ffffff; border-color: #1d4ed8; }
.btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%); }

.btn-success { background: linear-gradient(180deg, #10b981 0%, #059669 100%); color: #ffffff; border-color: #047857; }
.btn-success:hover:not(:disabled) { background: linear-gradient(180deg, #059669 0%, #047857 100%); }

.btn-warning { background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%); color: #ffffff; border-color: #b45309; }
.btn-warning:hover:not(:disabled) { background: linear-gradient(180deg, #d97706 0%, #b45309 100%); }

.btn-outline-primary { background: #ffffff; border-color: #93c5fd; color: var(--primary); }
.btn-outline-primary:hover:not(:disabled) { background: #eff6ff; border-color: var(--primary); }

.btn-danger-outline { background: transparent; border-color: #fca5a5; color: var(--danger); }
.btn-danger-outline:hover:not(:disabled) { background: #fef2f2; border-color: var(--danger); }

.btn-secondary { background: #ffffff; border-color: #cbd5e1; color: var(--text-main); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; }

/* --- 文件显示 --- */
.file-info {
    margin-top: 14px; padding: 12px 14px;
    background: #f8fafc; border: 1px solid var(--border-color); border-radius: var(--radius-md);
    display: flex; align-items: center; gap: 10px; font-size: 13.5px;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.02);
}
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.hint { margin-top: 10px; font-size: 12.5px; color: var(--warning); font-weight: 500;}

/* --- 右侧面板 --- */
.records-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.records-card { height: 100%; display: flex; flex-direction: column; }
.flex-header { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; }
.header-title-wrap { display: flex; align-items: center; gap: 12px; }
.record-count { font-size: 12.5px; font-weight: 700; color: var(--primary); background: #eff6ff; padding: 4px 10px; border-radius: 20px; }

.records-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding: 0; }

/* 选项卡 (调整得更像 Segmented Control) */
.tabs { display: flex; background: #f1f5f9; padding: 4px; border-radius: var(--radius-md); }
.tab {
    padding: 6px 16px; border: none; background: transparent; border-radius: 6px;
    font-size: 13px; font-weight: 600; color: var(--text-secondary); cursor: pointer; transition: var(--transition);
}
.tab.active { background: #ffffff; color: var(--primary); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }

.tab-content { display: none; flex: 1; min-height: 0; flex-direction: column; }
.tab-content.active { display: flex; }

/* 表格 (更现代的表头) */
.table-wrapper { flex: 1; overflow: auto; }
.scan-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.scan-table th {
    position: sticky; top: 0; z-index: 10;
    background: #f8fafc; color: var(--text-secondary);
    padding: 14px 16px; text-align: left; font-weight: 600; font-size: 13px;
    border-bottom: 2px solid var(--border-color);
    white-space: nowrap;
}
.scan-table td { padding: 14px 16px; border-bottom: 1px solid var(--border-color); color: var(--text-main); }
.scan-table tbody tr:hover { background: rgba(248, 250, 252, 0.8); }
.thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border-color); background: #fff; }

.badge { padding: 4px 10px; border-radius: 6px; font-size: 12px; font-weight: 600; }
.badge.pending { background: #f1f5f9; color: var(--text-secondary); }
.badge.processing { background: #eff6ff; color: var(--primary); }
.badge.success { background: #ecfdf5; color: var(--success); }
.badge.skip { background: #fffbeb; color: var(--warning); }
.badge.failed { background: #fef2f2; color: var(--danger); }

/* 空状态 */
.empty-row td { padding: 0 !important; border: none !important; }
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 100px 20px; }
.empty-icon-wrap { color: #cbd5e1; margin-bottom: 20px; background: #f8fafc; padding: 20px; border-radius: 50%; }
.empty-state p { font-size: 16px; font-weight: 600; color: var(--text-main); margin-bottom: 6px; }
.empty-hint { font-size: 13.5px; color: var(--text-muted); }

/* 日志 (终端风格) */
.log-list { flex: 1; overflow-y: auto; background: #0f172a; color: #e2e8f0; padding: 16px 20px; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.7; }
.log-item { padding: 3px 0; border-bottom: 1px solid rgba(255,255,255,0.03); white-space: pre-wrap; }
.log-item.info { color: #94a3b8; }
.log-item.success { color: #34d399; }
.log-item.warn { color: #fbbf24; }
.log-item.error { color: #f87171; }
.log-empty { text-align: center; padding: 40px 0; color: #64748b; font-family: inherit; }

/* --- 弹窗 --- */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(15,23,42,0.5); backdrop-filter: blur(4px);
    display: none; align-items: center; justify-content: center; z-index: 2000; padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
    background: #ffffff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    width: 100%; max-width: 480px; max-height: 90vh; display: flex; flex-direction: column;
    animation: scaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid var(--border-color);
}
.scan-modal { max-width: 600px; }
@keyframes scaleIn { from { opacity: 0; transform: scale(0.95) translateY(10px); } to { opacity: 1; transform: scale(1) translateY(0); } }

.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; background: #f8fafc; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--text-main); }
.modal-close { background: transparent; border: none; color: var(--text-muted); cursor: pointer; padding: 6px; border-radius: 6px; transition: var(--transition); }
.modal-close:hover { background: #e2e8f0; color: var(--text-main); }

.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 18px 24px; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 12px; background: #f8fafc; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

.settings-title { font-size: 13.5px; font-weight: 700; color: var(--text-main); margin: 24px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border-color); }
.settings-title:first-child { margin-top: 0; }

/* 扫码弹窗 */
.scan-header-info { display: flex; justify-content: space-between; margin-bottom: 16px; align-items: flex-end; }
.scan-progress { font-family: monospace; font-size: 16px; font-weight: 700; color: var(--primary); }
.scan-current { font-size: 13.5px; color: var(--text-secondary); font-weight: 500; }
.scan-preview {
    width: 100%; height: 300px; background: #f8fafc; border: 2px dashed #cbd5e1; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center; overflow: hidden; position: relative;
}
.scan-preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: none; }
.scan-preview-empty { color: var(--text-muted); font-size: 14px; font-weight: 500; }
.scan-input { font-size: 20px; font-family: monospace; text-align: center; height: 48px; font-weight: 700; color: var(--primary); letter-spacing: 2px; }

/* Toast */
.toast-container { position: fixed; top: 24px; right: 24px; z-index: 3000; display: flex; flex-direction: column; gap: 10px; }
.toast {
    background: #ffffff; border-radius: var(--radius-md); box-shadow: var(--shadow-md);
    padding: 14px 20px; font-size: 13.5px; font-weight: 500; border-left: 4px solid var(--primary);
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes slideInRight { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: translateX(0); } }
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }

/* ========================================
   引擎加载进度条
   ======================================== */
.engine-load-progress {
    display: none;
    margin-top: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-md);
    padding: 12px;
    animation: fadeIn 0.3s;
}
.progress-text {
    font-size: 12px;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.progress-track {
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #3b82f6, #60a5fa);
    border-radius: 3px;
    transition: width 0.2s ease;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}