        :root {
            --primary: #4361ee;
            --success: #2ec4b6;
            --warning: #ff9f1c;
            --danger: #e71d36;
            --bg: #f0f2f5;
            --card-bg: #ffffff;
            --text: #2b2d42;
            --text-light: #8d99ae;
        }
        * { box-sizing: border-box; }
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
            background: var(--bg);
            color: var(--text);
            margin: 0;
            padding: 0;
            min-height: 100vh;
            padding-bottom: 60px;
        }

        /* Header */
        .app-header {
            background: linear-gradient(135deg, var(--primary), #3a0ca3);
            color: white;
            padding: 20px 24px;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .app-header h1 {
            font-size: 20px;
            font-weight: 600;
            margin: 0;
            letter-spacing: 0.5px;
        }
        .app-header .subtitle {
            font-size: 12px;
            opacity: 0.8;
            margin-top: 2px;
        }

        /* Tabs */
        .tab-bar {
            display: flex;
            background: var(--card-bg);
            border-bottom: 1px solid #e9ecef;
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        .tab-bar::-webkit-scrollbar { display: none; }
        .tab-item {
            flex: 1;
            min-width: 72px;
            padding: 12px 8px;
            text-align: center;
            cursor: pointer;
            border-bottom: 3px solid transparent;
            transition: all 0.2s;
            user-select: none;
        }
        .tab-item:hover { background: #f8f9fa; }
        .tab-item.active {
            border-bottom-color: var(--primary);
            color: var(--primary);
            font-weight: 600;
        }
        .tab-item .tab-icon { font-size: 20px; display: block; margin-bottom: 2px; }
        .tab-item .tab-label { font-size: 11px; color: var(--text-light); }
        .tab-item.active .tab-label { color: var(--primary); }

        /* Content */
        .content { padding: 16px; max-width: 960px; margin: 0 auto; }
        .panel { display: none; }
        .panel.active { display: block; }

        /* Cards */
        .card {
            background: var(--card-bg);
            border-radius: 12px;
            box-shadow: 0 1px 3px rgba(0,0,0,0.08);
            margin-bottom: 16px;
            overflow: hidden;
        }
        .card-header-custom {
            padding: 16px 20px;
            border-bottom: 1px solid #f0f0f0;
            display: flex;
            align-items: center;
            justify-content: space-between;
        }
        .card-header-custom h5 {
            margin: 0;
            font-size: 16px;
            font-weight: 600;
        }
        .card-body-custom { padding: 20px; }

        /* Form */
        .form-group { margin-bottom: 16px; }
        .form-label {
            font-size: 13px;
            font-weight: 500;
            color: var(--text-light);
            margin-bottom: 6px;
            display: block;
        }
        .form-input {
            width: 100%;
            padding: 10px 14px;
            border: 1.5px solid #e0e0e0;
            border-radius: 8px;
            font-size: 15px;
            transition: border-color 0.2s;
            outline: none;
            background: #fafafa;
        }
        .form-input:focus {
            border-color: var(--primary);
            background: white;
            box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
        }
        .form-row {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 12px;
        }
        @media (min-width: 640px) {
            .form-row { grid-template-columns: 1fr 1fr 1fr; }
        }

        /* Buttons */
        .btn {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
            padding: 12px 24px;
            border: none;
            border-radius: 10px;
            font-size: 15px;
            font-weight: 600;
            cursor: pointer;
            transition: all 0.2s;
            width: 100%;
        }
        .btn:active { transform: scale(0.98); }
        .btn-primary { background: var(--primary); color: white; }
        .btn-primary:hover { background: #3451d1; }
        .btn-success { background: var(--success); color: white; }
        .btn-success:hover { background: #26a89c; }
        .btn-warning { background: var(--warning); color: white; }
        .btn-warning:hover { background: #e68d15; }
        .btn-outline {
            background: transparent;
            border: 1.5px solid #e0e0e0;
            color: var(--text);
        }
        .btn-outline:hover { border-color: var(--primary); color: var(--primary); }
        .btn-sm {
            padding: 6px 14px;
            font-size: 13px;
            width: auto;
            border-radius: 8px;
        }

        /* Table */
        .table-wrap { overflow-x: auto; }
        table {
            width: 100%;
            border-collapse: collapse;
            table-layout: auto; /* 内容决定列宽，自动调整 */
        }
        th {
            font-size: 12px;
            font-weight: 600;
            color: var(--text-light);
            text-transform: uppercase;
            letter-spacing: 0.5px;
            padding: 10px 12px;
            border-bottom: 2px solid #f0f0f0;
            white-space: nowrap;
            position: relative;
            user-select: none;
        }
        td {
            padding: 12px;
            border-bottom: 1px solid #f5f5f5;
            font-size: 14px;
            vertical-align: middle;
            white-space: nowrap; /* 默认不换行，防止挤压 */
            overflow: hidden;
            text-overflow: ellipsis;
        }
        /* 名称列允许适当换行，但限制最大宽度 */
        td:nth-child(2), th:nth-child(2) {
            white-space: normal;
            max-width: 200px;
        }
        /* 列宽拖拽手柄 */
        .resize-handle {
            position: absolute;
            right: 0;
            top: 0;
            bottom: 0;
            width: 5px;
            cursor: col-resize;
            z-index: 10;
            transition: background 0.2s;
        }
        .resize-handle:hover, .resize-handle.dragging {
            background: var(--primary);
        }
        tr:hover td { background: #f8f9fa; }
        .sku-badge {
            display: inline-block;
            background: #edf2ff;
            color: var(--primary);
            padding: 3px 10px;
            border-radius: 6px;
            font-weight: 600;
            font-size: 13px;
        }
        .stock-ok { color: var(--success); font-weight: 600; }
        .stock-low { color: var(--danger); font-weight: 600; }
        .type-badge {
            display: inline-block;
            padding: 2px 8px;
            border-radius: 4px;
            font-size: 12px;
            font-weight: 500;
        }
        .type-in { background: #d4edda; color: #155724; }
        .type-out { background: #fff3cd; color: #856404; }
        .type-return { background: #d1ecf1; color: #0c5460; }
        .type-loss { background: #f8d7da; color: #721c24; }

        /* Status bar */
        .status-bar {
            position: fixed;
            bottom: 0;
            left: 0;
            right: 0;
            background: var(--text);
            color: white;
            padding: 8px 20px;
            font-size: 12px;
            display: flex;
            justify-content: space-between;
            align-items: center;
            z-index: 100;
        }
        .status-dot {
            width: 8px;
            height: 8px;
            border-radius: 50%;
            display: inline-block;
            margin-right: 6px;
        }
        .status-dot.ok { background: var(--success); }
        .status-dot.err { background: var(--danger); }
        .status-dot.wait { background: var(--warning); }

        /* Toast */
        .toast-container {
            position: fixed;
            top: 20px;
            right: 20px;
            z-index: 200;
        }
        .toast-msg {
            padding: 12px 20px;
            border-radius: 10px;
            color: white;
            font-size: 14px;
            font-weight: 500;
            margin-bottom: 8px;
            animation: slideIn 0.3s ease;
            box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        }
        .toast-msg.success { background: var(--success); }
        .toast-msg.error { background: var(--danger); }
        .toast-msg.info { background: var(--primary); }
        @keyframes slideIn {
            from { transform: translateX(100px); opacity: 0; }
            to { transform: translateX(0); opacity: 1; }
        }

        /* Empty state */
        .empty-state {
            text-align: center;
            padding: 40px 20px;
            color: var(--text-light);
        }
        .empty-state i { font-size: 48px; margin-bottom: 12px; display: block; }
        .empty-state p { margin: 0; font-size: 14px; }

        /* Hint text */
        .hint {
            font-size: 12px;
            color: var(--text-light);
            margin-top: 4px;
        }

        /* Active issues indicator */
        .active-count {
            background: var(--danger);
            color: white;
            font-size: 11px;
            padding: 2px 8px;
            border-radius: 10px;
            font-weight: 600;
        }
        .btn-return {
            background: var(--primary);
            color: white;
            border: none;
            padding: 4px 12px;
            border-radius: 6px;
            font-size: 12px;
            font-weight: 500;
            cursor: pointer;
            white-space: nowrap;
            transition: all 0.2s;
        }
        .btn-return:hover { background: #3451d1; }

        /* ===== Login Page ===== */
        .login-page {
            display: flex; align-items: center; justify-content: center;
            min-height: 100vh; background: linear-gradient(135deg, #4361ee, #3a0ca3);
            padding: 20px;
        }
        .login-box {
            background: white; border-radius: 16px; padding: 40px 36px;
            width: 100%; max-width: 380px; box-shadow: 0 20px 60px rgba(0,0,0,0.3);
        }
        .login-box h1 { font-size: 22px; font-weight: 700; text-align: center; margin-bottom: 4px; }
        .login-box p { text-align: center; color: var(--text-light); font-size: 14px; margin-bottom: 28px; }
        .login-box .form-input { background: #f5f6f8; border-color: transparent; margin-bottom: 0; }
        .login-box .form-input:focus { background: white; }
        .login-box .btn { margin-top: 8px; }
        .login-error { color: var(--danger); font-size: 13px; text-align: center; margin-top: 12px; min-height: 20px; }

        /* ===== Return Modal ===== */
        .modal-overlay {
            display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.5);
            z-index: 500; align-items: center; justify-content: center; padding: 20px;
        }
        .modal-overlay.show { display: flex; }
        .modal-box {
            background: white; border-radius: 16px; padding: 28px 24px;
            width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,0.25);
        }
        .modal-box h3 { margin: 0 0 4px 0; font-size: 18px; font-weight: 700; }
        .modal-box .sub { color: var(--text-light); font-size: 13px; margin-bottom: 20px; }
        .modal-box .info-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 14px; }
        .modal-box .info-row .label { color: var(--text-light); }
        .modal-box .info-row .val { font-weight: 600; }
        .modal-box .divider { border: none; border-top: 1px solid #eee; margin: 16px 0; }
        .modal-box .btn-row { display: flex; gap: 10px; margin-top: 20px; }
        .modal-box .btn-row .btn { flex: 1; }

        /* ===== Active Issues Grouped List ===== */
        .active-search { width: 100%; padding: 10px 14px; border: 1.5px solid #e0e0e0; border-radius: 10px; font-size: 14px; outline: none; }
        .active-search:focus { border-color: var(--primary); }
        .person-group { border-bottom: 1px solid #f0f0f0; }
        .person-group:last-child { border-bottom: none; }
        .person-header {
            display: flex; align-items: center; justify-content: space-between;
            padding: 14px 18px; cursor: pointer; user-select: none;
            background: #f8f9fe; transition: background 0.15s;
        }
        .person-header:hover { background: #eef0fe; }
        .person-header .name { font-weight: 600; font-size: 15px; color: var(--primary); }
        .person-header .badge { background: var(--primary); color: white; border-radius: 12px; padding: 2px 10px; font-size: 12px; font-weight: 600; }
        .person-header .arrow { transition: transform 0.2s; color: var(--text-light); font-size: 12px; }
        .person-header .arrow.open { transform: rotate(90deg); }
        .person-body { display: none; }
        .person-body.open { display: block; }
        .person-body table { margin: 0; }
        .person-body td:first-child { padding-left: 24px; }

        /* ===== Safety Stock Inline Edit ===== */
        .stock-editable {
            cursor: pointer; padding: 2px 6px; border-radius: 4px;
            transition: background 0.15s; display: inline-block; min-width: 30px; text-align: center;
        }
        .stock-editable:hover { background: #eef0fe; }
        .stock-editable:focus { outline: 2px solid var(--primary); background: white; }

        /* ===== Loss Stats ===== */
        .stat-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 12px; margin-bottom: 16px; }
        .stat-card { background: #f8f9fe; border-radius: 12px; padding: 16px; text-align: center; }
        .stat-card .num { font-size: 28px; font-weight: 700; color: var(--primary); }
        .stat-card .lbl { font-size: 12px; color: var(--text-light); margin-top: 4px; }
        @media (max-width: 500px) {
            .stat-grid { grid-template-columns: 1fr 1fr; }
            .app-header { flex-wrap: wrap; padding: 12px 16px; gap: 6px; }
            .app-header h1 { font-size: 17px; }
            .app-header .subtitle { font-size: 11px; }
            #headerRightRow { gap: 8px !important; font-size: 12px !important; }
            .inbound-sku-row { flex-wrap: wrap; }
            .inbound-sku-row .form-input { flex: 0 0 100% !important; }
            .inbound-sku-row .btn { flex: 1; min-width: 0; padding: 10px 6px !important; font-size: 12px !important; }
        }

        /* ===== Scan Line Animation ===== */
        @keyframes scanLine {
            0%, 100% { top: 5%; }
            50% { top: 90%; }
        }