/* 全局样式 */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    background: #f5f7fa;
    color: #333;
    font-size: 14px;
}

/* 布局 */
.layout {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: 200px;
    background: #1a237e;
    color: white;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.logo {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.logo h2 {
    font-size: 20px;
    margin-bottom: 5px;
}

.logo p {
    font-size: 12px;
    opacity: 0.8;
}

.menu a {
    display: block;
    padding: 11px 16px 11px 28px;
    margin: 0 10px 2px 10px;
    color: rgba(255, 255, 255, 0.78);
    text-decoration: none;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.menu a:hover {
    background: rgba(255, 255, 255, 0.12);
    color: white;
}

.menu a.active {
    background: rgba(255, 255, 255, 0.18);
    color: white;
    font-weight: 600;
    border-left-color: #ff6f00;
    box-shadow: inset 0 0 12px rgba(255, 111, 0, 0.08);
}

/* 分组标题 */
.menu-group {
    margin-bottom: 6px;
}

.menu-group + .menu-group {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 6px;
}

.menu-group-title {
    padding: 8px 18px 6px;
    font-size: 13px;
    font-weight: 700;
    color: rgba(255, 200, 100, 0.85);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    user-select: none;
}

/* 侧边栏底部用户区 */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(0, 0, 0, 0.12);
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 600;
    color: white;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
}

.sidebar-user-actions a {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75) !important;
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar-user-actions a:hover {
    color: white !important;
    text-decoration: underline;
}

/* 高频快捷按钮区域 */
.quick-actions {
    padding: 10px 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 4px;
}

.quick-btn {
    display: block;
    width: 100%;
    padding: 9px 12px;
    background: rgba(255, 111, 0, 0.85);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.quick-btn:hover {
    background: rgba(255, 111, 0, 1);
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: 200px;
    min-height: 100vh;
}

.topbar {
    background: white;
    padding: 14px 25px;
    border-bottom: 1px solid #e8e8e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.topbar h1 {
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: 0.3px;
}

.user {
    color: #555;
    font-size: 14px;
}

.page-content {
    padding: 25px;
    background: #f5f6fa;
    min-height: calc(100vh - 64px);
}

/* 登录页 */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a237e 0%, #3949ab 100%);
}

.login-box {
    background: white;
    padding: 32px;
    border-radius: 8px;
    width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.login-box .logo {
    border-bottom: none;
    padding: 0;
    color: #1a237e;
}

.login-box .logo p {
    opacity: 1;
    color: #666;
}

/* 卡片 */
.card {
    background: white;
    border-radius: 10px;
    padding: 22px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid #f0f0f0;
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 18px;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
    color: #1a1a1a;
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar input,
.toolbar select {
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

.toolbar input:focus,
.toolbar select:focus {
    outline: none;
    border-color: #1a237e;
}

/* 按钮 */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-primary {
    background: #1a237e;
    color: white;
    box-shadow: 0 2px 4px rgba(26, 35, 126, 0.2);
}

.btn-primary:hover {
    background: #283593;
    box-shadow: 0 3px 6px rgba(26, 35, 126, 0.28);
}

.btn-success {
    background: #2e7d32;
    color: white;
    box-shadow: 0 2px 4px rgba(46, 125, 50, 0.2);
}

.btn-success:hover {
    background: #388e3c;
    box-shadow: 0 3px 6px rgba(46, 125, 50, 0.28);
}

.btn-danger {
    background: #c62828;
    color: white;
    box-shadow: 0 2px 4px rgba(198, 40, 40, 0.2);
}

.btn-danger:hover {
    background: #d32f2f;
    box-shadow: 0 3px 6px rgba(198, 40, 40, 0.28);
}

.btn-secondary {
    background: #ffffff;
    color: #333;
    border: 1px solid #d9d9d9;
}

.btn-secondary:hover {
    background: #f5f5f5;
    border-color: #bfbfbf;
}

.btn-small {
    padding: 5px 11px;
    font-size: 12px;
    border-radius: 5px;
}

/* Tab 切换 */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    border-bottom: 2px solid #e8e8e8;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 8px 20px;
    border: 1px solid #d9d9d9;
    background: #f5f5f5;
    color: #666;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #e8e8e8;
    color: #333;
}

.tab-btn.active {
    background: #1a237e;
    color: white;
    border-color: #1a237e;
    font-weight: 500;
    box-shadow: 0 2px 4px rgba(26, 35, 126, 0.2);
}

/* 状态标签 */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.badge-warning {
    background: #fff3e0;
    color: #ef6c00;
}

.badge-create { background: #e8f5e9; color: #2e7d32; }
.badge-update { background: #e3f2fd; color: #1565c0; }
.badge-delete { background: #ffebee; color: #c62828; }
.badge-audit { background: #f3e5f5; color: #6a1b9a; }
.badge-unaudit { background: #fff3e0; color: #ef6c00; }
.badge-settle { background: #e0f2f1; color: #00695c; }

/* 表格 */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 13px 16px;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}

.data-table th {
    background: #f7f8fc;
    font-weight: 600;
    color: #555;
    font-size: 13px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
    position: sticky;
    top: 50px;
    z-index: 2;
}

.data-table tr:hover {
    background: #fafbff;
}

.data-table .actions {
    white-space: nowrap;
}

/* 弹窗内表格滚动容器：表头固定，内容滚动 */
.table-scroll-wrapper {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid #f0f0f0;
    border-radius: 6px;
    margin-top: 10px;
}

.table-scroll-wrapper .data-table {
    margin-top: 0;
}

.table-scroll-wrapper .data-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f7f8fc;
}

/* 生成销售单/价格比对/进销历史弹窗表格：禁用 sticky 表头，避免手机端遮挡首行数据 */
.generate-sale-items th,
.price-compare-items th,
.history-items th {
    position: relative !important;
    top: auto !important;
}

/* 表单 */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #555;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
    font-size: 14px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* 配件搜索弹窗：桌面端折叠控件默认隐藏 */
.mobile-search-summary {
    display: none;
}
.mobile-search-form {
    display: block;
}

/* 模态框 */
body.modal-open {
    overflow: hidden !important;
    touch-action: none !important;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    min-height: 100vh;
    min-height: 100dvh;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header {
    padding: 15px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #f0f0f0;
    text-align: right;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.close-btn {
    font-size: 24px;
    cursor: pointer;
    color: #999;
    background: none;
    border: none;
}

.close-btn:hover {
    color: #333;
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.stat-card .label {
    color: #888;
    font-size: 13px;
    margin-bottom: 8px;
}

.stat-card .value {
    font-size: 24px;
    font-weight: 600;
    color: #1a237e;
}

.stat-card .value.danger {
    color: #c62828;
}

.stat-card .value.success {
    color: #2e7d32;
}

/* 历史记录弹窗 */
.history-modal {
    z-index: 1100;
}
.history-modal .modal {
    max-width: 1100px;
    width: 90%;
}

.history-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.history-tabs button {
    padding: 8px 16px;
    border: 1px solid #d9d9d9;
    background: white;
    cursor: pointer;
    border-radius: 4px;
}

.history-tabs button.active {
    background: #1a237e;
    color: white;
    border-color: #1a237e;
}

/* 手机端字段标签（PC端隐藏） */
.mobile-label { display: none; }

/* 开单项列表 */
.item-list {
    border: 1px solid #e8e8e8;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.item-header {
    display: grid;
    grid-template-columns: 2fr 1.6fr 0.7fr 0.9fr 0.9fr 0.9fr 0.7fr 0.5fr 60px 60px 60px;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
    padding-bottom: 8px;
    border-bottom: 2px solid #e0e0e0;
    font-weight: bold;
    font-size: 13px;
    color: #333;
}

.item-header span {
    text-align: center;
}

.item-row {
    display: grid;
    grid-template-columns: 2fr 1.6fr 0.7fr 0.9fr 0.9fr 0.9fr 0.7fr 0.5fr 60px 60px 60px;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #f0f0f0;
}

.item-row.purchase-row {
    grid-template-columns: 2fr 1.6fr 0.7fr 1fr 1fr 0.5fr 0.7fr 70px 70px;
}

.part-image-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
}

.has-image {
    color: #2e7d32;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border: 1px solid #2e7d32;
    border-radius: 4px;
    display: inline-block;
    background: #e8f5e9;
}

.has-image:hover {
    background: #c8e6c9;
}

/* 配件管理列表中标识已有图片的“图片”按钮 */
.btn.btn-has-image {
    color: #fff;
    background: #16a34a;
    border: 1px solid #15803d;
}
.btn.btn-has-image:hover {
    background: #15803d;
}

.no-image {
    color: #999;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 6px;
    border: 1px dashed #d9d9d9;
    border-radius: 4px;
    display: inline-block;
}

.no-image:hover {
    color: #1890ff;
    border-color: #1890ff;
}

.image-share-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border: 1px solid #f0f0f0;
    border-radius: 4px;
    background: #fafafa;
}

.image-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.item-row:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.item-row input,
.item-row select {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #d9d9d9;
    border-radius: 4px;
}

.item-row input[readonly] {
    background: #f5f5f5;
}

.item-row input:focus,
.item-row select:focus {
    outline: none;
    border-color: #1890ff;
    box-shadow: 0 0 0 2px rgba(24, 144, 255, 0.2);
}

.add-part-btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(24, 144, 255, 0.4);
}

.image-upload-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.image-upload-controls input[type="file"] {
    display: none;
}

.image-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

.selected-count {
    color: #666;
    font-size: 14px;
}

/* Toast */
.toast {
    position: fixed;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 12px 20px;
    border-radius: 4px;
    color: white;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
    /* 支持多行消息换行（批量校验错误清单等），限制宽度避免撑爆屏幕 */
    max-width: 80vw;
    white-space: pre-line;
    text-align: center;
    line-height: 1.6;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.toast.success {
    background: #2e7d32;
}

.toast.error {
    background: #c62828;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate(-50%, -60%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #999;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 15px;
}

.pagination button {
    padding: 6px 12px;
    border: 1px solid #d9d9d9;
    background: white;
    cursor: pointer;
    border-radius: 4px;
}

.pagination button.active {
    background: #1a237e;
    color: white;
    border-color: #1a237e;
}

.pagination button:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

/* Tab 标签页 */
.tab-nav {
    display: flex;
    border-bottom: 2px solid #e8e8e8;
    margin-bottom: 16px;
    background: #fff;
    padding: 0 4px;
}

.tab-nav-item {
    padding: 12px 20px;
    cursor: pointer;
    color: #666;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    font-size: 14px;
    transition: all 0.2s;
}

.tab-nav-item:hover {
    color: #1890ff;
}

.tab-nav-item.active {
    color: #1890ff;
    border-bottom-color: #1890ff;
    font-weight: 500;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ===== 移动端响应式适配 ===== */
/* 汉堡菜单按钮（默认隐藏，手机端显示） */
.menu-toggle {
    display: none;
}
/* 侧边栏遮罩层（默认隐藏） */
.sidebar-overlay {
    display: none;
}

@media (max-width: 768px) {
    /* ===== 侧边栏改抽屉式 ===== */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        width: 240px;
        height: 100vh;
        z-index: 1001;
        transition: left 0.3s ease;
    }
    /* 侧边栏展开状态 */
    .sidebar.open {
        left: 0;
    }
    /* 遮罩层显示 */
    .sidebar-overlay.show {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
    }
    .logo h2,
    .logo p {
        display: block;
    }
    .menu a {
        padding: 14px 20px;
        text-align: left;
        font-size: 14px;
    }

    .sidebar-footer {
        padding: 14px 18px;
    }

    .sidebar-user-actions a {
        font-size: 13px;
    }

    /* ===== 主内容区 ===== */
    .main-content {
        margin-left: 0;
        width: 100%;
    }

    /* ===== 顶部栏 ===== */
    .topbar {
        padding: 10px 12px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .topbar h1 {
        font-size: 16px;
        flex: 1;
        min-width: 0;
    }
    /* 汉堡按钮显示 */
    .menu-toggle {
        display: flex;
        flex-direction: column;
        justify-content: space-around;
        width: 28px;
        height: 28px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 0;
        flex-shrink: 0;
    }
    .menu-toggle span {
        display: block;
        width: 100%;
        height: 3px;
        background: #1a237e;
        border-radius: 2px;
    }
    .user {
        font-size: 12px;
        display: flex;
        align-items: center;
        gap: 6px;
        flex-shrink: 0;
    }
    .user button {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* ===== 页面内容区 ===== */
    .page-content {
        padding: 12px;
    }

    /* 手机端卡片内表格不固定表头，避免overflow-x:auto容器与sticky冲突遮挡首行 */
    .card .data-table th,
    .generate-sale-items th,
    .price-compare-items th {
        position: relative !important;
        top: auto !important;
    }

    /* ===== 卡片 ===== */
    .card {
        padding: 12px;
        margin-bottom: 12px;
        border-radius: 6px;
        overflow-x: auto; /* 表格横向滚动 */
        -webkit-overflow-scrolling: touch;
    }
    .card-title {
        font-size: 14px;
        margin-bottom: 10px;
    }

    /* ===== 统计卡片 ===== */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .stat-card {
        padding: 14px;
    }

    /* ===== 表格横向滚动 ===== */
    .table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .data-table {
        min-width: 600px;
    }
    .data-table th,
    .data-table td {
        padding: 8px 10px;
        font-size: 13px;
        white-space: nowrap;
    }

    /* ===== 工具栏 ===== */
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .toolbar input,
    .toolbar select {
        width: 100%;
    }

    /* ===== 表单 ===== */
    .form-row {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* iOS防止自动缩放 */
    }

    /* ===== 弹窗全屏 + 可滚动 ===== */
    .modal {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 100vh !important;
        height: 100vh !important;
        border-radius: 0 !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .modal-header {
        padding: 10px 14px !important;
        flex-shrink: 0 !important;
    }
    .modal-body {
        padding: 14px !important;
        flex: 1 !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .modal-footer {
        padding: 10px 14px !important;
        flex-shrink: 0 !important;
        flex-wrap: wrap;
    }
    .modal-footer .btn {
        flex: 1;
        min-width: 100px;
    }

    /* ===== Tab切换 ===== */
    .tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 6px;
    }
    .tab-btn {
        white-space: nowrap;
        padding: 6px 14px;
        font-size: 13px;
    }

    /* ===== 按钮间距 ===== */
    .btn {
        padding: 8px 12px;
        font-size: 13px;
    }
    .btn-small {
        padding: 4px 8px;
        font-size: 11px;
    }

    /* ===== 登录页 ===== */
    .login-box {
        width: 92%;
        padding: 20px;
    }

    /* ===== 开单配件列表：卡片式布局 ===== */
    .item-header { display: none !important; }
    .item-row {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px;
        padding: 12px;
        margin-bottom: 12px;
        border: 1px solid #e5e7eb;
        border-radius: 8px;
        background: #f9fafb;
    }
    .item-row > * { width: 100% !important; max-width: 100% !important; }
    .item-row input {
        height: 44px;
        font-size: 16px;
        padding: 8px 12px;
    }
    /* 隐藏number输入框的spinner箭头 */
    .item-row input[type="number"]::-webkit-inner-spin-button,
    .item-row input[type="number"]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    .item-row input[type="number"] { -moz-appearance: textfield; }
    /* 隐藏次要字段 */
    .item-row input[readonly] { display: none !important; }
    .item-row .btn-small.btn-secondary { display: none !important; } /* 隐藏F6/F7历史按钮 */
    .item-row .part-image-cell { display: block !important; width: 100% !important; } /* 显示图片列 */
    /* 按钮缩小 */
    .item-row .btn-small { width: auto !important; align-self: flex-start; }
    /* 手机端字段标签 */
    .mobile-label {
        display: block !important;
        font-size: 13px;
        color: #666;
        margin-bottom: 2px;
        font-weight: 500;
    }

    /* ===== 配件搜索弹窗：手机端支持横纵滚动 ===== */
    .part-search-modal .modal {
        width: 100% !important;
        max-width: 100% !important;
        height: 100vh !important;
        height: 100dvh !important;
        max-height: 100vh !important;
        max-height: 100dvh !important;
        border-radius: 0 !important;
    }
    .part-search-modal .modal-body {
        flex: 1 !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
        /* 安全区 + 360 等浏览器底部工具栏预留 */
        padding-bottom: calc(env(safe-area-inset-bottom) + 56px) !important;
    }
    /* 手动录入模式和搜索模式的外层容器都自适应 */
    .part-search-modal .modal-body > div {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        min-height: 0 !important;
    }
    .part-search-modal .modal-body > div > * {
        flex-shrink: 0 !important;
    }
    .part-search-modal .modal-body > div > .part-search-table-wrap {
        flex: 1 !important;
        flex-shrink: 1 !important;
        max-height: none !important;
        /* 保证表格区域最小高度，不被底部按钮压成一条缝 */
        min-height: 200px !important;
        min-height: 30vh !important;
        overflow: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }
    .part-search-table-wrap table {
        min-width: 520px;
    }
    .pagination-bar {
        flex-shrink: 0 !important;
        padding-bottom: 10px !important;
    }
    /* 手机端搜索条件折叠 */
    .mobile-search-summary {
        display: none;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 10px 0;
        border-bottom: 1px solid #f0f0f0;
        margin-bottom: 8px;
    }
    .mobile-search-summary.form-collapsed {
        display: flex;
        border-bottom: none;
        margin-bottom: 0;
    }
    .mobile-search-keyword {
        font-size: 14px;
        color: #333;
        font-weight: 500;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        flex: 1;
    }
    .mobile-search-form {
        display: block;
    }
    .mobile-search-form.form-collapsed {
        display: none !important;
    }
    /* 候选下拉框手机端缩小高度 */
    .part-search-modal .sug-dropdown {
        max-height: 120px !important;
        overflow-y: auto !important;
    }
    .part-search-modal .form-row {
        gap: 8px !important;
        margin-bottom: 0 !important;
    }
    .part-search-modal .form-group {
        margin-bottom: 4px !important;
    }
    .part-search-modal .form-group label {
        margin-bottom: 1px !important;
        font-size: 12px !important;
    }
    .part-search-modal .form-group input {
        height: 32px !important;
        padding: 4px 8px !important;
        font-size: 14px !important;
    }
    .part-search-modal .pagination-bar {
        padding-top: 6px !important;
        padding-bottom: 6px !important;
    }
    .part-search-modal .pagination-bar .btn {
        padding: 4px 10px !important;
        font-size: 13px !important;
    }

    /* ===== 所有包含表格的容器强制横向滚动 ===== */
    div:has(> .data-table) {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    .data-table {
        min-width: 600px;
    }
}

/* 超小屏（<=375px）进一步优化 */
@media (max-width: 375px) {
    .page-content {
        padding: 8px;
    }
    .card {
        padding: 10px;
    }
    .topbar h1 {
        font-size: 14px;
    }
    .stat-card {
        padding: 10px;
    }
    .data-table th,
    .data-table td {
        padding: 6px 8px;
        font-size: 12px;
    }
}

/* 可搜索下拉框高亮样式 */
.searchable-select .dropdown > div:hover,
.searchable-select .dropdown > div.active-option {
    background: #1890ff;
    color: #fff;
}

/* 配件搜索弹窗高亮行：仅依靠 .active-row 类，不使用 :hover 伪类。
   原因：键盘方向键移动 highlightedIndex 时，鼠标物理位置没变，:hover 伪类会导致旧行残留蓝色。
   @mouseover 已经在鼠标移动经过时同步了 highlightedIndex，新行会获得 .active-row 类，相当于 hover 效果 */
.part-search-modal .data-table tbody tr.active-row {
    background: #1890ff;
    color: #fff;
}
.part-search-modal .data-table tbody tr.active-row td[style*="sticky"] {
    background: #1890ff;
    color: #fff;
}

/* 配件搜索弹窗表格区域 */
.part-search-table-wrap {
    flex: 1;
    overflow: auto;
    margin-top: 12px;
    position: relative;
    max-height: 420px;
    border: 1px solid #e5e7eb;
    border-radius: 4px;
}
.part-search-table-wrap::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
.part-search-table-wrap::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 5px;
}
.part-search-table-wrap::-webkit-scrollbar-track {
    background: #f1f1f1;
}
.part-search-table-wrap table {
    border-collapse: collapse;
    min-width: 700px;
    width: 100%;
}
.part-search-table-wrap thead th {
    position: sticky;
    top: 0;
    background: #f3f4f6;
    z-index: 3;
    white-space: nowrap;
}
.part-search-table-wrap thead th:first-child {
    left: 0;
    z-index: 5;
}
.part-search-table-wrap tbody td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
}
.part-search-table-wrap tbody tr.active-row td:first-child {
    background: #1890ff;
}
/* 历史购买过的配件行标记 */
.part-search-table-wrap tbody tr.history-row {
    background: #fff7e6;
}
.part-search-table-wrap tbody tr.history-row.active-row {
    background: #1890ff;
}
.part-search-table-wrap tbody tr.history-row td:first-child {
    background: #fff7e6;
}
.part-search-table-wrap tbody tr.history-row.active-row td:first-child {
    background: #1890ff;
}
.history-badge {
    display: inline-block;
    background: #fa8c16;
    color: #fff;
    font-size: 11px;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
}
.sug-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #d1d5db;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 999;
    max-height: 220px;
    overflow-y: auto;
}
.search-btn-wrap {
    position: relative;
    z-index: 1000;
}
.sug-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    border-bottom: 1px solid #f3f4f6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sug-item:last-child { border-bottom: none; }
.sug-item:hover { background: #1890ff; color: #fff; }
.sug-item-active { background: #1890ff !important; color: #fff !important; }

/* 可清除输入框 */
.clearable-input {
    position: relative;
    display: flex;
    align-items: center;
}
.clearable-input input {
    width: 100%;
    padding-right: 24px;
    box-sizing: border-box;
}
.clear-btn {
    position: absolute;
    right: 6px;
    color: #aaa;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    display: none;
    user-select: none;
}
.clearable-input:hover .clear-btn,
.clearable-input input:focus ~ .clear-btn {
    display: block;
}
.clear-btn:hover { color: #555; }

/* 隐藏 number 输入框的上下箭头 */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type=number] {
    -moz-appearance: textfield;
}
.searchable-select .dropdown > div:hover .detail,
.searchable-select .dropdown > div.active-option .detail {
    color: rgba(255,255,255,0.85);
}

/* AI 助手页面 */
.ai-agent-page {
    height: calc(100vh - 80px);
    padding: 20px;
}

.ai-agent-page .chat-card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    height: 100%;
    display: flex;
    flex-direction: column;
    max-width: 900px;
    margin: 0 auto;
}

.ai-agent-page .chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ai-agent-page .chat-header h3 {
    margin: 0;
    font-size: 18px;
}

.ai-agent-page .chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.ai-agent-page .chat-message {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
}

.ai-agent-page .chat-message.user {
    align-items: flex-end;
}

.ai-agent-page .chat-message.assistant {
    align-items: flex-start;
}

.ai-agent-page .chat-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 14px;
}

.ai-agent-page .chat-message.user .chat-bubble {
    background: #1a73e8;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-agent-page .chat-message.assistant .chat-bubble {
    background: white;
    color: #333;
    border: 1px solid #e8e8e8;
    border-bottom-left-radius: 4px;
}

.ai-agent-page .chat-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.ai-agent-page .chat-footer {
    padding: 16px 20px;
    border-top: 1px solid #eee;
    background: white;
    border-radius: 0 0 10px 10px;
}

.ai-agent-page .quick-actions-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 10px;
    margin-bottom: 8px;
    background: #f5f6fa;
    border: 1px solid #e4e6f0;
    border-radius: 6px;
    color: #555;
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.ai-agent-page .quick-actions-toggle:hover {
    background: #eef0f7;
}

.ai-agent-page .quick-actions-toggle .toggle-arrow {
    font-size: 11px;
    color: #888;
    transition: transform 0.2s ease;
}

.ai-agent-page .quick-actions-toggle .toggle-arrow.open {
    transform: rotate(180deg);
}

/* 单据识别入库明细表格：不使用sticky表头，避免与overflow-x:auto容器冲突导致行内容被遮挡 */
.invoice-items-table th {
    position: relative !important;
    top: auto !important;
    z-index: auto !important;
}

.ai-agent-page .quick-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.ai-agent-page .chat-input-row {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.ai-agent-page .plus-menu-row {
    display: flex;
    gap: 6px;
    padding: 4px 0 8px 0;
    flex-wrap: wrap;
}

.ai-agent-page .chat-input-row textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #ddd;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    min-height: 42px;
    max-height: 120px;
}

.ai-agent-page .chat-input-row textarea:focus {
    outline: none;
    border-color: #1a73e8;
}

.ai-agent-page .confirm-actions {
    display: flex;
    gap: 10px;
}

/* ===== 打印预览弹窗表格样式 ===== */
.preview-sheet {
    background: #fff;
    padding: 20px 24px;
    border-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,.12);
    font-family: "Microsoft YaHei", SimSun, sans-serif;
    font-size: 13px;
    color: #000;
}
.preview-title {
    text-align: center;
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 12px;
    letter-spacing: 2px;
}
.preview-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0 20px;
    font-size: 12px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid #333;
}
.preview-meta span { line-height: 1.9; }
table.preview-items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
}
table.preview-items th,
table.preview-items td {
    border: 1px solid #333;
    padding: 5px 6px;
    text-align: center;
    font-size: 12px;
    word-break: break-all;
    vertical-align: middle;
}
table.preview-items th {
    background: #f0f0f0;
    font-weight: bold;
}
table.preview-items td.left { text-align: left; }
table.preview-items .total-row {
    font-weight: bold;
    background: #fafafa;
}
.preview-bottom {
    display: flex;
    flex-wrap: wrap;
    gap: 0 20px;
    font-size: 12px;
    padding: 6px 0;
    border-top: 1px solid #333;
    border-bottom: 1px solid #333;
    margin-bottom: 8px;
}
.preview-bottom span { line-height: 1.9; }
/* 合计金额高亮：两种销售单打印格式统一用显眼深红，方便客户一眼看到 */
.total-amount-highlight {
    color: #d9001b !important;
    font-weight: 700 !important;
    font-size: 15px !important;
}
/* 简洁版（黑白）预览：金额列统一红色，便于客户快速识别 */
table.preview-items td.amount-red {
    color: #d9001b;
    font-weight: 600;
}
.preview-address,
.preview-slogan,
.preview-remark {
    font-size: 12px;
    margin-top: 5px;
}

.preview-qr {
    position: absolute;
    right: 8mm;
    bottom: 8mm;
    text-align: center;
    font-size: 10px;
    color: #333;
}
.preview-qr img {
    width: 22mm;
    height: 22mm;
    display: block;
    margin-bottom: 2px;
}
.preview-sheet.unaudited.last-page .preview-bottom,
.preview-sheet.unaudited.last-page .preview-address,
.preview-sheet.unaudited.last-page .preview-slogan,
.preview-sheet.unaudited.last-page .preview-remark {
    padding-right: 28mm;
}

/* ===== 销售单完整版彩色预览样式（A4 比例，仅用于导出图片） ===== */
#print-area-full {
    font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
}
#print-area-full .full-page {
    width: 210mm;
    min-width: 210mm;
    min-height: 297mm;
    padding: 12mm 10mm;
    box-sizing: border-box;
    background: #fff;
    color: #2c3e50;
    font-size: 13px;
    position: relative;
    margin: 0 auto 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
#print-area-full .full-watermark {
    position: absolute;
    top: 24px;
    right: 28px;
    width: 86px;
    height: 86px;
    border: 3px solid rgba(220, 38, 38, 0.65);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 19px;
    color: rgba(220, 38, 38, 0.65);
    font-weight: bold;
    letter-spacing: 2px;
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: 10;
    background: transparent;
}
#print-area-full .full-header {
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 2px solid #4a6fa5;
    padding-bottom: 10px;
    margin-bottom: 12px;
    position: relative;
    z-index: 1;
}
#print-area-full .full-logo {
    width: 110px;
    flex-shrink: 0;
}
#print-area-full .full-logo img {
    width: 100%;
    height: auto;
    display: block;
}
#print-area-full .full-title-wrap {
    text-align: center;
}
#print-area-full .full-title {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    letter-spacing: 2px;
    line-height: 1.3;
}
#print-area-full .full-subtitle {
    font-size: 16px;
    color: #4a6fa5;
    font-weight: 600;
    margin-top: 4px;
    letter-spacing: 6px;
}
#print-area-full .full-meta {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #cfd8e3;
    position: relative;
    z-index: 1;
}
#print-area-full .full-meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0 24px;
    line-height: 1.9;
}
#print-area-full .full-meta-row span {
    white-space: nowrap;
}
#print-area-full .full-items {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 10px;
    table-layout: fixed;
    position: relative;
    z-index: 1;
    border: 1.5px solid #4a6fa5;
}
#print-area-full .full-items th,
#print-area-full .full-items td {
    border: 1px solid #b0c4de;
    padding: 5px 6px;
    text-align: center;
    vertical-align: middle;
    word-wrap: break-word;
    white-space: nowrap;
}
/* 编码/名称/车型/产地允许折行（超长双图号、长名称）；序号/数量/单价/金额/备注强制单行 */
#print-area-full .full-items th:nth-child(2),
#print-area-full .full-items td:nth-child(2),
#print-area-full .full-items th:nth-child(3),
#print-area-full .full-items td:nth-child(3),
#print-area-full .full-items th:nth-child(4),
#print-area-full .full-items td:nth-child(4),
#print-area-full .full-items th:nth-child(6),
#print-area-full .full-items td:nth-child(6) {
    white-space: normal;
}
#print-area-full .full-items th {
    background: #e8eef7;
    color: #2c3e50;
    font-weight: 700;
    font-size: 13px;
}
#print-area-full .full-items td.left { text-align: left; }
#print-area-full .full-items td.right { text-align: right; }
#print-area-full .full-items .full-total-row {
    background: #f2f6fb;
    font-weight: 600;
}
#print-area-full .full-finance {
    margin-bottom: 12px;
    padding: 8px 0;
    border-top: 1px solid #cfd8e3;
    border-bottom: 1px solid #cfd8e3;
    position: relative;
    z-index: 1;
}
#print-area-full .full-promo {
    position: relative;
    z-index: 1;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #cfd8e3;
}
#print-area-full .full-promo-main {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}
#print-area-full .full-promo-text {
    flex: 1;
    font-size: 12px;
    line-height: 1.8;
    color: #3d4f6f;
}
#print-area-full .full-promo-text div {
    margin-bottom: 4px;
}
#print-area-full .full-promo-tip {
    margin-top: 6px;
    color: #555;
}
#print-area-full .full-promo-qr {
    text-align: center;
    font-size: 11px;
    color: #666;
    flex-shrink: 0;
}
#print-area-full .full-promo-qr img {
    width: 22mm;
    height: 22mm;
    display: block;
    margin: 0 auto 3px;
}
#print-area-full .full-promo-qr .qr-cap-t {
    font-size: 12px;
    font-weight: bold;
    color: #c0392b;
    line-height: 1.3;
}
#print-area-full .full-promo-qr .qr-cap-s {
    font-size: 9px;
    line-height: 1.35;
    color: #666;
}
#print-area-full .full-promo-contact {
    margin-top: 10px;
    font-size: 12px;
    color: #555;
    text-align: center;
}

/* ===== 销售单 217mm x 140mm 针式纸预览样式（与打印样式一致，实际有效打印宽度217mm） ===== */
.preview-sheet.sales-print {
    width: 217mm;
    min-width: 217mm;
    height: 140mm;
    min-height: 140mm;
    padding: 7mm 6mm;
    margin: 0 auto;
    box-sizing: border-box;
    font-size: 13px;
    color: #000;
    position: relative;
    overflow: hidden;
    page-break-after: always;
}
.preview-sheet.sales-print:last-child {
    page-break-after: auto;
}
.preview-sheet.sales-print .preview-watermark {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 64px;
    height: 64px;
    border: 2px solid rgba(220, 38, 38, 0.55);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: rgba(220, 38, 38, 0.55);
    font-weight: bold;
    letter-spacing: 1px;
    transform: rotate(-15deg);
    pointer-events: none;
    z-index: 10;
    background: transparent;
}
.preview-sheet.sales-print .preview-title {
    font-size: 22px;
    font-weight: 500;
    margin-bottom: 10px;
    letter-spacing: 1px;
}
.preview-sheet.sales-print .preview-meta {
    font-size: 14px;
    margin-bottom: 6px;
    border-bottom: 1px solid #000;
    padding-bottom: 5px;
    gap: 0 30px;
}
.preview-sheet.sales-print .preview-meta span {
    margin-right: 0;
    line-height: 1.5;
}
.preview-sheet.sales-print table.preview-items {
    table-layout: fixed;
    margin-bottom: 6px;
}
.preview-sheet.sales-print table.preview-items th,
.preview-sheet.sales-print table.preview-items td {
    border: 1px solid #000;
    padding: 1px 4px;
    font-size: 13px;
    line-height: 1.35;
}
.preview-sheet.sales-print table.preview-items th {
    font-size: 14px;
    font-weight: normal;
    background: #f0f0f0;
}
.preview-sheet.sales-print table.preview-items td.left { text-align: left; }
.preview-sheet.sales-print table.preview-items th:nth-child(1),
.preview-sheet.sales-print table.preview-items td:nth-child(1) { width: 6%; white-space: nowrap; }
.preview-sheet.sales-print table.preview-items th:nth-child(2),
.preview-sheet.sales-print table.preview-items td:nth-child(2) { width: 18%; }
/* 名称列：允许占2行 */
.preview-sheet.sales-print table.preview-items th:nth-child(3),
.preview-sheet.sales-print table.preview-items td:nth-child(3) { width: 24%; text-align: left; word-break: normal; white-space: normal; }
/* 车型列：不换行，超长截断加省略号（车型字数多的情况极少，优先保证行高一致） */
.preview-sheet.sales-print table.preview-items th:nth-child(4),
.preview-sheet.sales-print table.preview-items td:nth-child(4) { width: 10%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-sheet.sales-print table.preview-items th:nth-child(5),
.preview-sheet.sales-print table.preview-items td:nth-child(5) { width: 7%; }
/* 产地列：不换行，超长截断（产地不全不影响点货） */
.preview-sheet.sales-print table.preview-items th:nth-child(6),
.preview-sheet.sales-print table.preview-items td:nth-child(6) { width: 10%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-sheet.sales-print table.preview-items th:nth-child(7),
.preview-sheet.sales-print table.preview-items td:nth-child(7) { width: 9%; text-align: right; }
.preview-sheet.sales-print table.preview-items th:nth-child(8),
.preview-sheet.sales-print table.preview-items td:nth-child(8) { width: 10%; text-align: right; }
/* 备注列：窄列截断，跟序号一样 */
.preview-sheet.sales-print table.preview-items th:nth-child(9),
.preview-sheet.sales-print table.preview-items td:nth-child(9) { width: 6%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.preview-sheet.sales-print .preview-bottom {
    font-size: 13px;
    padding: 6px 0;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    gap: 0 30px;
    margin-bottom: 6px;
}
.preview-sheet.sales-print .preview-bottom span {
    margin-right: 0;
    line-height: 1.8;
}
.preview-sheet.sales-print .preview-remark { font-size: 13px; margin-top: 8px; }
.preview-sheet.sales-print .preview-address { font-size: 13px; margin-top: 8px; }
.preview-sheet.sales-print .preview-slogan { font-size: 12px; margin-top: 8px; }

/* 销售退货单打印列宽覆盖（比销售单少车型/产地两列） */
.preview-sheet.return-print table.preview-items th:nth-child(1),
.preview-sheet.return-print table.preview-items td:nth-child(1) { width: 48px; white-space: nowrap; }
.preview-sheet.return-print table.preview-items th:nth-child(2),
.preview-sheet.return-print table.preview-items td:nth-child(2) { width: 160px; }
.preview-sheet.return-print table.preview-items th:nth-child(3),
.preview-sheet.return-print table.preview-items td:nth-child(3) { width: 260px; text-align: left; word-break: normal; white-space: normal; }
.preview-sheet.return-print table.preview-items th:nth-child(4),
.preview-sheet.return-print table.preview-items td:nth-child(4) { width: 70px; }
.preview-sheet.return-print table.preview-items th:nth-child(5),
.preview-sheet.return-print table.preview-items td:nth-child(5) { width: 80px; text-align: right; }
.preview-sheet.return-print table.preview-items th:nth-child(6),
.preview-sheet.return-print table.preview-items td:nth-child(6) { width: 90px; text-align: right; }
.preview-sheet.return-print table.preview-items th:nth-child(7),
.preview-sheet.return-print table.preview-items td:nth-child(7) { width: 80px; }
.preview-sheet.return-print .preview-footer { font-size: 12px; margin-top: 8px; }

/* ===== 单据识别 loading 动画 ===== */
.ocr-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: ocr-spin 1s linear infinite;
    flex-shrink: 0;
}
@keyframes ocr-spin {
    to { transform: rotate(360deg); }
}

/* ===== 线索询价浮动通知 ===== */
.lead-notify-badge {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 9999;
    background: #ff4d4f;
    color: #fff;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(255,77,79,0.4);
    animation: lead-pulse 2s infinite;
    font-size: 18px;
}
.lead-badge-count {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #faad14;
    color: #fff;
    border-radius: 10px;
    padding: 0 6px;
    font-size: 11px;
    line-height: 18px;
    font-weight: bold;
}
@keyframes lead-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}
.lead-notify-panel {
    position: fixed;
    top: 70px;
    right: 20px;
    z-index: 9998;
    width: 360px;
    max-width: calc(100vw - 40px);
    max-height: 420px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.lead-notify-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #fff;
    font-weight: bold;
    font-size: 15px;
}
.lead-notify-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}
.lead-notify-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}
.lead-notify-item {
    padding: 10px 12px;
    border-bottom: 1px solid #f0f0f0;
    border-radius: 8px;
    margin-bottom: 4px;
    background: #fafafa;
}
.lead-notify-item:hover {
    background: #f0f5ff;
}
.lead-notify-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #888;
    margin-bottom: 4px;
}
.lead-channel {
    background: #e6f7ff;
    color: #1890ff;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
}
.lead-notify-content {
    font-size: 14px;
    color: #333;
    line-height: 1.4;
}
.lead-notify-type {
    margin-top: 4px;
    font-size: 12px;
    color: #666;
}
.lead-notify-footer {
    padding: 10px 16px;
    border-top: 1px solid #f0f0f0;
    text-align: center;
}
.lead-notify-footer button {
    background: #667eea;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 20px;
    cursor: pointer;
    font-size: 13px;
}
.lead-notify-footer button:hover {
    background: #5a6fd6;
}

/* 嵌入的智能客服 / 批量报价页面 */
.kf-embed-wrap {
    margin: -25px;
    height: calc(100vh - 64px);
    min-height: 520px;
    background: #fff;
}
.kf-embed-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
.kf-embed-tip {
    padding: 60px 25px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* 客服新消息提醒卡片（右下角） */
.kf-notify-card {
    position: fixed;
    right: 20px;
    bottom: 20px;
    z-index: 9997;
    width: 300px;
    max-width: calc(100vw - 40px);
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.18);
    overflow: hidden;
}
.kf-notify-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: #667eea;
    color: #fff;
    font-size: 14px;
    font-weight: bold;
}
.kf-notify-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}
.kf-notify-body {
    padding: 12px 14px;
    font-size: 13px;
    color: #333;
    line-height: 1.5;
    word-break: break-all;
}
.kf-notify-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px 12px;
}
.kf-notify-sub {
    font-size: 12px;
    color: #999;
}
