/* ==================== CSS Variables ==================== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --success-color: #16a34a;
    --danger-color: #dc2626;
    --warning-color: #f59e0b;
    --bg-color: #f1f5f9;
    --sidebar-bg: #1e293b;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
}

/* ==================== Reset & Base ==================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
}

/* ==================== Layout ==================== */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==================== Sidebar ==================== */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    color: white;
    display: flex;
    flex-direction: column;
    padding: 20px 0;
    flex-shrink: 0;
}

.logo {
    padding: 0 24px 30px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo h2 {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 4px;
}

.logo span {
    font-size: 12px;
    color: rgba(255,255,255,0.5);
}

.nav-menu {
    flex: 1;
    padding: 20px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    margin-bottom: 4px;
    cursor: pointer;
}

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

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

.nav-item .icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.server-status {
    padding: 16px 24px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: rgba(255,255,255,0.6);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ef4444;
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success-color);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ==================== Main Content ==================== */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
}

.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

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

.page-header h1 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ==================== Stats Cards ==================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    box-shadow: var(--shadow);
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
}

.stat-icon.blue { background: #dbeafe; }
.stat-icon.green { background: #dcfce7; }
.stat-icon.orange { background: #fef3c7; }
.stat-icon.purple { background: #f3e8ff; }

.stat-info h3 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-info p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ==================== Chart ==================== */
.chart-container {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.chart-container h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
}

#brandChart {
    min-height: 300px;
}

.brand-bar {
    margin-bottom: 12px;
}

.brand-label {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 13px;
}

.bar-track {
    height: 24px;
    background: #e2e8f0;
    border-radius: 6px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #60a5fa);
    border-radius: 6px;
    transition: width 0.6s ease;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 10px;
    color: white;
    font-size: 11px;
    font-weight: 600;
}

/* ==================== Search Bar ==================== */
.search-bar, .filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.search-bar input,
.search-bar select,
.filter-bar select {
    padding: 10px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-bar input:focus,
.search-bar select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.search-bar input {
    flex: 1;
    min-width: 200px;
}

.search-bar select {
    width: 150px;
}

/* ==================== Table ==================== */
.table-container {
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.data-table th {
    background: #334155;
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid #1e293b;
}

.data-table td {
    padding: 14px 16px;
    font-size: 15px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-color);
}

.data-table tr:nth-child(even) td {
    background: #f8fafc;
}

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

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

.loading {
    text-align: center;
    padding: 40px !important;
    color: #64748b;
    font-size: 15px;
}

/* ========== 表格徽章 ========== */
.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
}
.badge-in { background: #dcfce7; color: #166534; }
.badge-out { background: #fee2e2; color: #991b1b; }

/* ==================== Buttons ==================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    background: #f1f5f9;
    color: var(--text-primary);
}

.btn:hover {
    background: #e2e8f0;
}

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

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

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

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

.btn-block {
    width: 100%;
    padding: 12px;
}

/* ==================== Pagination ==================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination button.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination .page-info {
    color: var(--text-secondary);
    font-size: 13px;
}

/* ==================== Operations Grid ==================== */
.operations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 24px;
}

.operation-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 28px;
    box-shadow: var(--shadow);
}

.operation-card h3 {
    font-size: 18px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

/* ==================== Form ==================== */
.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group.full-width {
    grid-column: span 2;
}

.form-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.form-group input,
.form-group textarea,
.form-group select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

/* ==================== Modal ==================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 720px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px;
    border-bottom: 1px solid var(--border-color);
}

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

.close-btn {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.modal-content form {
    padding: 28px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
}

/* ==================== Toast ==================== */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    background: #1e293b;
    color: white;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success-color);
}

.toast.error {
    background: var(--danger-color);
}

/* ==================== Hamburger Menu ==================== */
.menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1100;
    width: 40px;
    height: 36px;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    padding: 8px 6px;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.menu-toggle:hover {
    background: #1d4ed8;
    transform: scale(1.05);
}

.menu-toggle:active {
    transform: scale(0.95);
}

.menu-toggle span {
    display: block;
    width: 24px;
    height: 3px;
    background: #fff;
    border-radius: 3px;
    transition: all 0.3s ease;
    transform-origin: center;
}

/* 侧边栏展开状态 */
.sidebar.open {
    left: 0;
}

/* 遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }

    .sidebar {
        position: fixed;
        left: -260px;
        z-index: 100;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.3);
    }

    .main-content {
        padding: 16px;
        padding-top: 60px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .operations-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-group.full-width {
        grid-column: span 1;
    }

    .search-bar {
        flex-direction: column;
    }

    .search-bar input,
    .search-bar select {
        width: 100%;
    }

    .data-table {
        font-size: 12px;
    }

    .data-table th,
    .data-table td {
        padding: 10px 8px;
    }
}

/* ==================== 登录覆盖层 ==================== */
.login-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1e293b 0%, #334155 50%, #1e293b 100%);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.login-overlay.active {
    display: flex;
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 40px;
    width: 400px;
    max-width: 90vw;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    animation: loginSlideIn 0.4s ease-out;
}

@keyframes loginSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header h1 {
    font-size: 28px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.login-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-field input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: #f8fafc;
}

.login-field input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #fff;
}
.login-field select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    background: #f8fafc;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    cursor: pointer;
}

.login-field select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background: #fff;
}


.login-error {
    color: var(--danger-color);
    font-size: 13px;
    min-height: 18px;
    text-align: center;
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

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

.login-btn:active {
    transform: scale(0.98);
}

.login-btn:disabled {
    background: var(--text-secondary);
    cursor: not-allowed;
}

/* 用户信息和登出按钮 */
.user-info {
    padding: 12px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.user-name {
    color: rgba(255,255,255,0.8);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-btn {
    padding: 4px 12px;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.7);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.logout-btn:hover {
    background: rgba(220,38,38,0.2);
    color: #fca5a5;
    border-color: rgba(220,38,38,0.3);
}

/* 移动端登录适配 */
@media (max-width: 480px) {
    .login-card {
        padding: 28px 20px;
    }
    .login-header h1 {
        font-size: 22px;
    }
}

/* ==================== 登录页面样式 ==================== */
.login-page {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 20px;
}

.login-card {
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
    animation: slideUp 0.5s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.logo-section {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    margin-bottom: 16px;
    animation: pulse 2s infinite;
}
.logo-icon img.login-logo-img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(44,62,80,0.3);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.app-name {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.app-desc {
    font-size: 14px;
    color: var(--text-secondary);
}

.login-form {
    margin-top: 24px;
}

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

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    transition: all 0.3s;
    background: white;
    color: var(--text-primary);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-control::placeholder {
    color: #cbd5e1;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.btn-login {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    margin-top: 8px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.btn-login:active {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.tips {
    margin-top: 16px;
    text-align: center;
}

.tips p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.footer {
    margin-top: 24px;
    text-align: center;
}

.version {
    font-size: 12px;
    color: var(--text-secondary);
}

/* 用户信息区域样式 */
.user-info-section {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255,255,255,0.05);
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.user-details {
    flex: 1;
    min-width: 0;
}

.username {
    color: white;
    font-size: 14px;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.permission-badge {
    color: rgba(255,255,255,0.7);
    font-size: 12px;
    margin-top: 2px;
}

.btn-logout {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.15);
    color: rgba(255,255,255,0.8);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-logout:hover {
    background: rgba(220,38,38,0.3);
    border-color: rgba(220,38,38,0.5);
    color: white;
    transform: scale(1.05);
}

/* Toast 通知样式增强 */
.toast.show {
    animation: toastSlideIn 0.3s ease-out;
}

@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* ========== 仪表盘 - 分类统计 ========== */
.card-header-row { display:flex; justify-content:space-between; align-items:center; margin-bottom:16px; }
.card-header-row h3 { margin:0; }
.category-stats-card { background:#fff; border-radius:8px; padding:20px; margin-top:20px; }
.category-stats-list { flex:1; overflow-y:auto; min-height:300px; }
.category-stats-list .bar-track { background:#e8ecf1; }
.category-stats-list .bar-fill { background:linear-gradient(90deg,#2c5aa0,#4a7fd4); }

/* ========== 芯片列表 - 行悬停 ========== */
.chip-row:hover { background:#f0f4ff !important; }
.text-danger { color:#e74c3c; font-weight:bold; }

/* ========== 出入库操作 ========== */
.op-mode-tabs { display:flex; gap:12px; margin-bottom:20px; }
.op-mode-tab { flex:1; padding:14px; border:2px solid #e0e0e0; border-radius:8px; font-size:16px; font-weight:bold; cursor:pointer; background:#fff; transition:all 0.3s; }
.op-mode-tab.in-tab.active { background:linear-gradient(135deg,#11998e,#38ef7d); color:#fff; border-color:transparent; }
.op-mode-tab.out-tab.active { background:linear-gradient(135deg,#fc4a1a,#f7b733); color:#fff; border-color:transparent; }
.op-search-bar { display:flex; gap:8px; margin-bottom:12px; }
.op-search-bar input { flex:1; }
.op-result-item { display:flex; justify-content:space-between; padding:10px 14px; border-bottom:1px solid #f0f0f0; cursor:pointer; }
.op-result-item:hover { background:#f5f5ff; }
.chip-preview-card { background:linear-gradient(135deg,#667eea,#764ba2); color:#fff; padding:16px 20px !important; }
.chip-preview { display:flex; align-items:center; gap:16px; }
.chip-preview-info { flex:1; }
.chip-preview-model { display:block; font-size:18px; font-weight:bold; }
.chip-preview-meta { display:block; font-size:13px; opacity:0.85; }
.chip-preview-stock { text-align:center; padding:0 16px; border-left:1px solid rgba(255,255,255,0.3); }
.stock-value { font-size:22px; font-weight:bold; display:block; }
.quick-btns { display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.quick-btns .btn-sm { padding:4px 12px; font-size:12px; }
.stock-warning { margin-top:8px; padding:8px 14px; background:#fff3f3; border:1px solid #fcc; border-radius:6px; color:#e74c3c; font-weight:bold; font-size:13px; }
.operation-form-card { padding:20px; }
.recent-ops-card {
    margin-top: 20px;
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}
.recent-ops-card h3 {
    font-size: 16px;
    color: var(--text-primary);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}
.recent-op-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 8px;
    border-bottom: 1px solid #e2e8f0;
    transition: background 0.2s;
}
.recent-op-item:hover { background: #f8fafc; }
.recent-op-item:last-child { border-bottom: none; }
.op-badge { width:36px;height:36px;border-radius:50%;display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:bold;color:#fff;flex-shrink:0; }
.op-badge.badge-in { background:#16a34a; }
.op-badge.badge-out { background:#dc2626; }
.op-desc { flex:1; font-size:15px; color:#1e293b; font-weight:500; }
.op-time { font-size:13px; color:#64748b; white-space:nowrap; }
.empty { text-align:center;color:#64748b;padding:32px 20px;margin:0;font-size:15px; }

/* ========== 弹窗 ========== */
.modal-sm { max-width:500px; }
.detail-content { padding:20px; }
.detail-content p { margin:6px 0; font-size:14px; color:#333; }
.detail-content b { color:#2c5aa0; }
#chipDetailModal .modal-header { background:linear-gradient(135deg,#2c5aa0,#4a7fd4); }
#chipDetailModal .modal-header h2 { color:#fff; }
#chipDetailModal .close-btn { color:#fff; }

/* ========== 通用 ========== */
.btn-warning { background:#f39c12; color:#fff; }

/* ===== 扫码出入库 ===== */
.btn-scan { background:linear-gradient(135deg,#667eea,#764ba2); color:#fff; white-space:nowrap; }
.btn-scan:hover { opacity:.9; }
.scan-modal-content { max-width:480px; width:92%; }
.scan-body { padding:16px; }
.scan-video-wrap { position:relative; width:100%; aspect-ratio:1/1; min-height:240px; background:#000; border-radius:12px; overflow:hidden; display:flex; align-items:center; justify-content:center; }
#scanVideo { width:100%; height:100%; object-fit:cover; }
.scan-frame { position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:62%; height:62%; border:2px solid rgba(76,175,80,.85); border-radius:12px; box-shadow:0 0 0 9999px rgba(0,0,0,.45); pointer-events:none; }
.scan-tip { text-align:center; color:#666; font-size:14px; margin:14px 0 6px; }
.scan-manual { margin-top:6px; }
.scan-manual summary { cursor:pointer; color:#667eea; font-size:13px; padding:6px 0; outline:none; }
.scan-manual textarea { width:100%; box-sizing:border-box; border:1px solid #ddd; border-radius:8px; padding:8px; font-size:13px; resize:vertical; margin:6px 0; }
.scan-footer { justify-content:center; gap:12px; }
.btn-sm { padding:4px 14px; font-size:12px; }
.stock-badge { font-size:13px; color:#667eea; }
.meta-text { font-size:14px; color:#888; }
#opChipSearch { display:block; }

/* ==================== BOM批量出库 ==================== */
.btn-bom { background: linear-gradient(135deg,#17a2b8,#138496); color: #fff; border: none; padding: 8px 14px; border-radius: 6px; cursor: pointer; font-size: 13px; transition: transform .15s, box-shadow .15s; white-space: nowrap; }
.btn-bom:hover { transform: translateY(-1px); box-shadow: 0 4px 10px rgba(23,162,184,.25); }
.bom-preview-card { margin-top: 16px; background: var(--card-bg); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); }
.bom-preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.bom-preview-header h3 { margin: 0; font-size: 15px; color: #2c3e50; }
.bom-preview-info { font-size: 12px; color: #666; margin-bottom: 8px; }
.bom-table-container { max-height: 320px; overflow-y: auto; margin-bottom: 10px; border: 1px solid var(--border-color); border-radius: 8px; }
.bom-table { font-size: 12px; width: 100%; border-collapse: collapse; }
.bom-table th, .bom-table td { padding: 6px 8px; white-space: nowrap; border-bottom: 1px solid var(--border-color); }
.bom-table th { background: #f8fafc; font-weight: 600; color: var(--text-primary); position: sticky; top: 0; }
.bom-table td:nth-child(3) { max-width: 160px; overflow: hidden; text-overflow: ellipsis; }
.bom-status { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 500; }
.bom-status.pending { background: #e9ecef; color: #495057; }
.bom-status.ok { background: #d4edda; color: #155724; }
.bom-status.short { background: #fff3cd; color: #856404; }
.bom-status.notfound { background: #f8d7da; color: #721c24; }
.bom-preview-actions { display: flex; gap: 10px; justify-content: flex-end; align-items: center; }
.bom-progress { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.progress-bar { flex: 1; height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg,#28a745,#20c997); border-radius: 4px; transition: width .3s ease; }
.bom-result { margin-top: 10px; padding: 10px 12px; border-radius: 6px; font-size: 13px; }
.bom-result-summary.ok { background: #d4edda; color: #155724; }
.bom-result-summary.mixed { background: #fff3cd; color: #856404; }
.bom-result-summary { padding: 8px 12px; border-radius: 6px; }
#bomOutboundBtn:disabled { opacity: .5; cursor: not-allowed; }
