/* ========== 全局 ========== */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --bg: #f0f2f5;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --card-bg: #ffffff;
    --text: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    --border: #e2e8f0;
    --success: #16a34a;
    --success-light: #dcfce7;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.15);
}

html, body {
    min-width: 1280px;
    overflow-x: auto;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    line-height: 1.6;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    font-family: inherit;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f8fafc; border-color: var(--text-light); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: #f59e0b; color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ========== 登录页 ========== */
.login-view {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e3a5f 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}
.login-logo {
    text-align: center;
    margin-bottom: 32px;
}
.login-logo svg { margin-bottom: 16px; }
.login-logo h1 {
    font-size: 22px;
    color: var(--text);
    font-weight: 700;
}
.login-subtitle {
    color: var(--text-muted);
    font-size: 14px;
    margin-top: 4px;
}
.login-form .form-group { margin-bottom: 20px; }
.login-error {
    background: var(--danger-light);
    color: var(--danger);
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
}

/* ========== 表单 ========== */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: #fff;
    color: var(--text);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { resize: vertical; }
.form-row {
    display: flex;
    gap: 16px;
}
.form-row .form-group { flex: 1; }
.required { color: var(--danger); }
.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal !important;
}
.checkbox-label input { width: auto !important; }

/* ========== 顶部栏 ========== */
.topbar {
    height: 56px;
    background: var(--sidebar-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-title { color: #fff; font-size: 16px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.topbar-user {
    color: #94a3b8;
    font-size: 14px;
}

/* 角色标签 */
.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    margin-left: 6px;
}
.role-badge.role-admin {
    background: #dc2626;
    color: #fff;
}
.role-badge.role-user {
    background: #475569;
    color: #cbd5e1;
}
.role-badge.role-super-admin {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #fff;
}
.topbar .btn-outline {
    border-color: #475569;
    color: #cbd5e1;
}
.topbar .btn-outline:hover {
    background: #334155;
    border-color: #64748b;
}

/* ========== 主布局 ========== */
.main-layout {
    display: flex;
    height: calc(100vh - 56px);
}

/* ========== 侧边栏 ========== */
.sidebar {
    width: 300px;
    min-width: 300px;
    background: #fff;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.sidebar-header {
    padding: 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.sidebar-title { font-weight: 700; font-size: 14px; }
.sidebar-search {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}
.sidebar-search input {
    width: 100%;
    padding: 8px 34px 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-search input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}
.search-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}
.search-btn {
    position: absolute;
    right: 28px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    padding: 0;
}
.search-btn:hover {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.08);
}
.search-clear-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 50%;
    transition: color 0.2s, background 0.2s;
    padding: 0;
}
.search-clear-btn:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}
.search-status {
    margin-top: 6px;
    font-size: 12px;
    min-height: 18px;
}
.search-loading { color: var(--text-muted); }
.search-no-result { color: var(--danger); }
.search-hit { color: var(--success); }
.tree-container {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

/* 树形节点 */
.tree-node { user-select: none; }
.tree-item {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    cursor: pointer;
    border-radius: 4px;
    gap: 4px;
    transition: background 0.15s;
}
.tree-item:hover { background: #f1f5f9; }
.tree-item.active { background: var(--primary-light); color: var(--primary-dark); font-weight: 600; }
.tree-toggle {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}
.tree-toggle.expanded { transform: rotate(90deg); }
.tree-toggle.leaf { visibility: hidden; }
.tree-icon {
    font-size: 14px;
    flex-shrink: 0;
}
.tree-label {
    flex: 1;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tree-badge {
    font-size: 11px;
    padding: 1px 7px;
    border-radius: 10px;
    font-weight: 600;
    flex-shrink: 0;
}
.tree-badge-own { background: var(--primary-light); color: var(--primary-dark); }
.tree-badge-archived { background: #fef3c7; color: #92400e; }
.tree-badge-count { background: #f1f5f9; color: var(--text-muted); }
.tree-children { display: none; }
.tree-children.show { display: block; }

.sidebar-footer {
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* ========== 主内容 ========== */
.content-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 联网查询窗口 */
.cross-search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 24px;
    background: #f0f5ff;
    border-bottom: 2px solid #2563eb;
    flex-shrink: 0;
}
.cross-search-label {
    font-weight: 600;
    font-size: 14px;
    color: #2563eb;
    white-space: nowrap;
}
.cross-search-input-wrap {
    display: flex;
    gap: 8px;
    flex: 1;
}
.cross-search-input-wrap input {
    flex: 1;
    padding: 7px 12px;
    border: 1.5px solid #2563eb;
    border-radius: 6px;
    font-size: 13px;
    outline: none;
}
.cross-search-input-wrap input:focus {
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

.content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
}

/* 欢迎页 */
.welcome {
    max-width: 700px;
    margin: 40px auto;
    text-align: center;
}
.welcome h2 { font-size: 24px; margin-bottom: 12px; }
.welcome p { color: var(--text-muted); margin-bottom: 8px; }
.welcome-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-top: 32px;
}
.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-card .stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

/* 物料详情卡片 */
.detail-card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.detail-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.detail-header h2 {
    font-size: 20px;
    font-weight: 700;
}
.detail-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
/* 分类内料号搜索框 */
.cat-search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.cat-search-box input {
    padding: 6px 30px 6px 12px;
    border: 1.5px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    width: 200px;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
}
.cat-search-box input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}
.cat-search-clear {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: none;
    background: #e2e8f0;
    color: var(--text-muted);
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.cat-search-clear:hover {
    background: #cbd5e1;
    color: var(--text);
}
.cat-search-count {
    font-size: 12px;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 4px;
}
.detail-body { padding: 20px 24px; }
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}
.detail-item {
    display: flex;
    flex-direction: column;
}
.detail-item .label {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.detail-item .value {
    font-size: 15px;
    font-weight: 500;
}
.detail-item .value a {
    color: var(--primary);
    text-decoration: none;
}
.detail-item .value a:hover { text-decoration: underline; }
.detail-item .detail-edit-input {
    font-size: 15px;
    font-weight: 500;
    padding: 4px 8px;
    min-height: 32px;
    border: 1px solid transparent;
    border-radius: 6px;
    background: transparent;
    transition: border-color 0.2s, background 0.2s;
    width: 100%;
    box-sizing: border-box;
}
.detail-item .detail-edit-input:hover {
    border-color: var(--border);
    background: #fafafa;
}
.detail-item .detail-edit-input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}
.detail-item-wide { grid-column: 1 / -1; }
.detail-item-wide .detail-edit-input { max-width: 100%; }

/* Pin-to-Pin 区域 */
.pin-section {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}
.pin-section-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.pin-section-header h3 { font-size: 16px; }
.pin-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
}
.pin-tab {
    padding: 10px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}
.pin-tab:hover { color: var(--text); }
.pin-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}
.pin-tab .tab-count {
    background: #f1f5f9;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    margin-left: 4px;
}
.pin-tab.active .tab-count { background: var(--primary-light); color: var(--primary-dark); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.data-table {
    width: 100%;
    border-collapse: collapse;
}
.data-table th {
    text-align: left;
    padding: 10px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}
.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}
.data-table tr:hover td { background: #f8fafc; }
.data-table tr:last-child td { border-bottom: none; }

/* 标签 */
.tag {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}
.tag-green { background: var(--success-light); color: var(--success); }
.tag-orange { background: var(--warning-light); color: var(--warning); }
.tag-blue { background: var(--primary-light); color: var(--primary-dark); }
.tag-purple { background: #ede9fe; color: #6d28d9; }
.tag-gray { background: #f1f5f9; color: var(--text-muted); }

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 15px; margin-bottom: 16px; }

/* 面包屑 */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-muted);
}
.breadcrumb span { color: var(--text-muted); }
.breadcrumb .sep { color: var(--text-light); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ========== 模态框 ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}
.modal {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}
.modal-lg { max-width: 640px; }
@keyframes modalIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}
.modal-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.modal-header h3 { font-size: 17px; }
.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}
.modal-close:hover { background: #f1f5f9; }
.modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}
.modal-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* 信息横幅 */
.info-banner {
    background: var(--primary-light);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--primary-dark);
}
.info-banner strong { font-weight: 700; }

/* ========== Toast ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text);
    color: #fff;
    padding: 12px 24px;
    border-radius: var(--radius);
    font-size: 14px;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* AI 反馈学习框 */
.ai-feedback-box input:focus,
.ai-feedback-box textarea:focus {
    outline: 2px solid #a78bfa;
    border-color: #a78bfa;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ========== 移动端导航 ========== */
.mobile-menu-toggle {
    display: none;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    margin-right: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.mobile-menu-toggle:hover { background: rgba(255,255,255,0.12); }

.mobile-sidebar-close {
    display: none;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
    margin-right: 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.mobile-sidebar-close:hover { background: rgba(0,0,0,0.08); }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 90;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

/* ========== 移动端：以完整桌面版缩放呈现，仅做必要微调 ========== */
/* viewport 已固定为 1280px，手机浏览器会自动把整页缩放到屏幕宽度，
   用户通过双指放大/拖动操作。以下媒体查询仅处理极小屏幕下机器人面板的可用性。 */
@media (max-width: 480px) {
    .bot-panel {
        width: 360px;
        max-width: calc(100vw - 24px);
        right: 12px;
        left: auto;
        bottom: 76px;
        height: 520px;
        max-height: calc(100vh - 100px);
    }
    .bot-fab { right: 14px; bottom: 14px; }
}

/* ========== 应用场景区域 ========== */
.scenario-section {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.scenario-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.scenario-header h3 { font-size: 16px; }
.scenario-body { padding: 20px 24px; }
.scenario-text {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text);
    white-space: pre-wrap;
    background: #f8fafc;
    border-radius: var(--radius);
    padding: 16px;
    margin-bottom: 16px;
    min-height: 20px;
}
.scenario-text.scenario-empty {
    color: var(--text-light);
    font-style: italic;
    background: #f8fafc;
}
.scenario-img-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 13px;
    background: #f8fafc;
    border-radius: var(--radius);
}
.scenario-images {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.scenario-img-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.2s;
}
.scenario-img-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.scenario-img-thumb {
    width: 100%;
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    cursor: pointer;
    overflow: hidden;
}
.scenario-img-thumb img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.2s;
}
.scenario-img-thumb:hover img { transform: scale(1.05); }
.scenario-img-desc {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text);
    border-bottom: 1px solid var(--border);
}
.scenario-img-meta {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-muted);
}
.scenario-img-meta .btn-sm { padding: 3px 10px; font-size: 12px; }

/* ========== 规格书文件区域 ========== */
.datasheet-section {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    overflow: hidden;
}
.datasheet-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.datasheet-header h3 { font-size: 16px; }
.datasheet-body { padding: 16px 24px; }
.datasheet-empty {
    text-align: center;
    padding: 24px;
    color: var(--text-light);
    font-size: 13px;
    background: #f8fafc;
    border-radius: var(--radius);
}
.datasheet-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.datasheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    transition: box-shadow 0.2s;
}
.datasheet-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.datasheet-item-icon {
    font-size: 28px;
    flex-shrink: 0;
}
.datasheet-item-info {
    flex: 1;
    min-width: 0;
}
.datasheet-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.datasheet-item-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.datasheet-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
/* 竞品表格中的规格书单元格 */
.pin-datasheet-cell {
    white-space: nowrap;
}

/* ========== 右键菜单 ========== */
.context-menu {
    position: fixed;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px 0;
    min-width: 140px;
    z-index: 3000;
    animation: contextMenuIn 0.15s ease;
}
@keyframes contextMenuIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}
.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text);
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.context-menu-item:hover {
    background: #f1f5f9;
}
.context-menu-item.context-menu-danger {
    color: var(--danger);
}
.context-menu-item.context-menu-danger:hover {
    background: var(--danger-light);
}
.context-menu-icon {
    font-size: 14px;
    flex-shrink: 0;
}

/* ========== 联网查询结果 ========== */
.cross-search-results {
    max-width: 100%;
}
.cross-search-summary {
    margin-bottom: 16px;
    padding: 12px 16px;
    background: #eff6ff;
    border-radius: 8px;
    color: #1e40af;
    font-size: 14px;
}
.cross-search-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.cross-search-table th {
    background: #1e40af;
    color: #fff;
    padding: 10px 12px;
    text-align: left;
    white-space: nowrap;
}
.cross-search-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.cross-search-table tbody tr:hover {
    background: #f0f5ff;
}
.cross-badge-pin {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #dcfce7;
    color: #166534;
}
.cross-badge-func {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #fef9c3;
    color: #854d0e;
}
.cross-badge-partial {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    background: #ede9fe;
    color: #6d28d9;
}
.cross-badge-own {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    background: #dbeafe;
    color: #1e40af;
}
.cross-badge-comp {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 11px;
    background: #f3f4f6;
    color: #6b7280;
}
.cross-link {
    color: #2563eb;
    cursor: pointer;
    text-decoration: underline;
}
.cross-link:hover {
    color: #1e40af;
}

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

/* ========== 搜索高亮 ========== */
.search-highlight {
    background: #fef9c3 !important;
    transition: background 0.3s;
}
.tree-item.search-highlight {
    background: #dbeafe;
    border-radius: 4px;
    font-weight: 600;
}
.data-table tbody tr.search-highlight {
    background: #fef9c3;
}
.data-table tbody tr.search-highlight:hover {
    background: #fef08a;
}

/* ========== 智能选型 ========== */
.smart-match-btn {
    margin-left: 8px;
    white-space: nowrap;
    background: linear-gradient(135deg, #3b82f6, #6366f1);
    color: #fff;
    border: none;
}
.smart-match-btn:hover {
    background: linear-gradient(135deg, #2563eb, #4f46e5);
}
.modal-xl {
    max-width: 95vw;
    max-height: 92vh;
    width: 1100px;
}
.modal-xl .modal-body {
    max-height: calc(92vh - 60px);
    overflow-y: auto;
}
.smart-match-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 16px;
}
.smart-match-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
    border-radius: 4px 4px 0 0;
}
.smart-match-tab:hover {
    color: #2563eb;
}
.smart-match-tab.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
    font-weight: 600;
}
.smart-match-panel {
    margin-bottom: 16px;
}
.smart-match-hint {
    color: #94a3b8;
    font-size: 13px;
    margin: 4px 0 8px;
}
.smart-match-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    box-sizing: border-box;
}
.smart-match-textarea:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.smart-match-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 32px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
}
.smart-match-upload-area:hover {
    border-color: #2563eb;
    background: #eff6ff;
}
.smart-match-upload-area p {
    margin: 4px 0;
    color: #475569;
    font-size: 14px;
}
.smart-match-extracted {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}
.smart-match-extracted label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    color: #334155;
    font-weight: 500;
}
.smart-match-actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    justify-content: center;
}
.smart-match-results {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
}

/* ========== Pin 资料上传 ========== */
.pin-docs-btn {
    margin-left: 8px;
    white-space: nowrap;
    background: linear-gradient(135deg, #f59e0b, #f97316);
    color: #fff;
    border: none;
}
.pin-docs-btn:hover {
    background: linear-gradient(135deg, #d97706, #ea580c);
}
.pin-docs-upload-area {
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    padding: 28px 16px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
}
.pin-docs-upload-area:hover {
    border-color: #f59e0b;
    background: #fffbeb;
}
.pin-docs-upload-area p {
    margin: 4px 0;
    color: #475569;
    font-size: 14px;
}
.pin-docs-file-list {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 160px;
    overflow-y: auto;
}
.pin-docs-file-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 10px;
    background: #f1f5f9;
    border-radius: 6px;
    font-size: 13px;
    color: #334155;
}
.pin-docs-file-item button {
    background: transparent;
    border: none;
    color: #ef4444;
    cursor: pointer;
    font-size: 13px;
}
.pin-docs-progress {
    margin-top: 12px;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}
.pin-docs-progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #f59e0b, #f97316);
    transition: width 0.3s;
}
.pin-docs-result {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid #e2e8f0;
    max-height: 320px;
    overflow-y: auto;
}
.pin-docs-result h4 {
    margin: 0 0 10px;
    font-size: 15px;
    color: #334155;
}
.pin-docs-stat {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}
.pin-docs-stat-item {
    background: #f8fafc;
    border-radius: 6px;
    padding: 8px;
    text-align: center;
}
.pin-docs-stat-value {
    font-size: 18px;
    font-weight: 700;
    color: #2563eb;
}
.pin-docs-stat-label {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}
.pin-docs-pair-row {
    display: flex;
    gap: 8px;
    font-size: 13px;
    padding: 5px 0;
    border-bottom: 1px solid #f1f5f9;
}
.pin-docs-pair-own {
    color: #2563eb;
    font-weight: 600;
    min-width: 110px;
}
.pin-docs-pair-target {
    color: #334155;
    flex: 1;
}
.pin-docs-pair-mfr {
    color: #64748b;
    min-width: 70px;
    text-align: right;
}

/* ========== 智能客服机器人 ========== */
/* 悬浮按钮 */
.bot-fab {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px 10px 10px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    border-radius: 50px;
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
    transition: all 0.25s;
    border: none;
    font-family: inherit;
}
.bot-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 28px rgba(37, 99, 235, 0.45); }
.bot-fab:active { transform: scale(0.96); }
.bot-fab.dragging {
    cursor: grabbing;
    transition: none !important;
    transform: none !important;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
}
.bot-fab-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}
.bot-fab-label { font-size: 14px; font-weight: 600; white-space: nowrap; }
.bot-fab-dot {
    position: absolute;
    top: 6px;
    right: 10px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #f43f5e;
    border: 2px solid #fff;
    display: none;
    animation: botPulse 1.5s infinite;
}
@keyframes botPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.5); }
    50% { box-shadow: 0 0 0 6px rgba(244, 63, 94, 0); }
}

/* 聊天面板 */
.bot-panel {
    position: fixed;
    right: 24px;
    bottom: 84px;
    z-index: 1001;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border);
    animation: botSlideUp 0.25s ease;
}
@keyframes botSlideUp {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* 头部 */
.bot-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}
.bot-header.dragging { cursor: grabbing; }
.bot-panel.dragging { transition: none !important; } /* 注意：不能设 animation:none，否则拖完移除该类后 botSlideUp 会从头重播导致面板跳动 */
.bot-header-grip {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.75;
    flex-shrink: 0;
    cursor: grab;
    padding: 2px;
    border-radius: 4px;
}
.bot-header.dragging .bot-header-grip { opacity: 1; }
.bot-header-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.bot-header-info { flex: 1; min-width: 0; }
.bot-header-title { font-size: 14px; font-weight: 700; }
.bot-header-status { font-size: 11px; opacity: 0.9; display: flex; align-items: center; gap: 4px; }
.bot-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    display: inline-block;
    animation: botPulseGreen 1.8s infinite;
}
@keyframes botPulseGreen {
    0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.6); }
    50% { box-shadow: 0 0 0 4px rgba(74, 222, 128, 0); }
}
.bot-header-close {
    width: 28px;
    height: 28px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.bot-header-close:hover { background: rgba(255, 255, 255, 0.3); }

/* 消息区 */
.bot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.bot-messages::-webkit-scrollbar { width: 6px; }
.bot-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.bot-msg { display: flex; gap: 8px; max-width: 100%; }
.bot-msg.user { justify-content: flex-end; }
.bot-msg.bot { justify-content: flex-start; }

.bot-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #4f46e5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 13px;
    margin-top: 2px;
}
.bot-msg-bubble {
    max-width: 78%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}
.bot-msg.user .bot-msg-bubble {
    background: var(--primary);
    color: #fff;
    border-top-right-radius: 3px;
}
.bot-msg.bot .bot-msg-bubble {
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    border-top-left-radius: 3px;
    box-shadow: var(--shadow);
}
.bot-msg.bot .bot-msg-bubble strong { color: var(--primary); }
.bot-msg.bot .bot-msg-bubble a { color: var(--primary); }
.bot-msg-time { font-size: 10px; color: var(--text-light); margin-top: 4px; }

/* 正在输入 */
.bot-typing { display: inline-flex; align-items: center; gap: 4px; padding: 4px 2px; }
.bot-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-light);
    animation: botTyping 1.2s infinite;
}
.bot-typing span:nth-child(2) { animation-delay: 0.2s; }
.bot-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes botTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* 贴边隐藏小条 */
.bot-edge-dock {
    position: fixed;
    z-index: 1002;
    width: 38px;
    height: 96px;
    background: linear-gradient(180deg, #2563eb, #4f46e5);
    color: #fff;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.35);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s, width 0.2s;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    opacity: 0.92;
}
.bot-edge-dock:hover { opacity: 1; transform: scale(1.05); }
.bot-edge-dock.dragging { transition: none !important; opacity: 1; }
.bot-edge-dock-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    pointer-events: none;
}
/* 贴边位置类 */
.bot-edge-dock.edge-right { right: 0; left: auto; border-radius: 12px 0 0 12px; }
.bot-edge-dock.edge-left { left: 0; right: auto; border-radius: 0 12px 12px 0; }
.bot-edge-dock.edge-top { top: 0; bottom: auto; left: 0; right: auto; width: 96px; height: 38px; border-radius: 0 0 12px 12px; }
.bot-edge-dock.edge-bottom { bottom: 0; top: auto; left: 0; right: auto; width: 96px; height: 38px; border-radius: 12px 12px 0 0; }
.bot-edge-dock.edge-top .bot-edge-dock-inner,
.bot-edge-dock.edge-bottom .bot-edge-dock-inner { transform: rotate(90deg); }

/* 右键菜单 */
.bot-context-menu {
    position: fixed;
    z-index: 1010;
    min-width: 140px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    padding: 6px;
    font-size: 13px;
    color: var(--text);
    overflow: hidden;
    animation: botCtxFade 0.15s ease;
}
@keyframes botCtxFade {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.bot-context-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    white-space: nowrap;
}
.bot-context-item:hover { background: #f1f5f9; color: var(--primary); }
.bot-context-item.hidden { display: none; }

/* 快捷问题 */
.bot-quick-asks {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 12px;
    background: #fff;
    border-top: 1px solid var(--border);
}
.bot-quick-chip {
    padding: 4px 10px;
    font-size: 12px;
    border: 1px solid var(--primary-light);
    background: #eff6ff;
    color: var(--primary-dark);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    white-space: nowrap;
}
.bot-quick-chip:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 输入区 */
.bot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid var(--border);
}
.bot-input-area textarea {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 13px;
    font-family: inherit;
    resize: none;
    max-height: 90px;
    outline: none;
    line-height: 1.5;
    transition: border-color 0.2s;
}
.bot-input-area textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1); }
.bot-send-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.bot-send-btn:hover { background: var(--primary-dark); }
.bot-send-btn:disabled { background: var(--text-light); cursor: not-allowed; }
.bot-disclaimer {
    font-size: 10px;
    color: var(--text-light);
    text-align: center;
    padding: 4px 8px 8px;
    background: #fff;
}

@media (max-width: 480px) {
    .bot-panel { right: 12px; bottom: 76px; width: calc(100vw - 24px); height: 60vh; }
    .bot-fab { right: 14px; bottom: 14px; }
}

/* ========== 批量上传规格书 ========== */
.bulk-dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 28px 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
    margin-top: 8px;
}
.bulk-dropzone:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.bulk-file-list { max-height: 180px; overflow-y: auto; }
.bulk-summary {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
}
.bulk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bulk-table th {
    background: #f1f5f9;
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--border);
}
.bulk-table td { padding: 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.bulk-table tr:hover { background: #f8fafc; }

/* ========== 批量上传规格书 ========== */
.bulk-dropzone {
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 28px 16px;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    background: #f8fafc;
    margin-top: 8px;
}
.bulk-dropzone:hover { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.bulk-file-list { max-height: 180px; overflow-y: auto; }
.bulk-summary {
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
}
.bulk-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bulk-table th {
    background: #f1f5f9;
    padding: 8px 6px;
    text-align: left;
    font-weight: 600;
    position: sticky;
    top: 0;
    z-index: 1;
    border-bottom: 1px solid var(--border);
}
.bulk-table td { padding: 6px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.bulk-table tr:hover { background: #f8fafc; }
