
        :root {
            --primary-color: #00a8e8;
            --primary-dark: #0077b6;
            --success-color: #00c853;
            --danger-color: #ff5252;
            --bg-dark: #0d1117;
            --bg-card: #161b22;
            --bg-input: #21262d;
            --border-color: #30363d;
            --text-primary: #f0f6fc;
            --text-secondary: #8b949e;
            --sidebar-width: 380px;
        }

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

        body {
            display: flex;
            height: 100vh;
            overflow: hidden;
            font-family: 'Inter', 'Noto Sans TC', sans-serif;
            background: var(--bg-dark);
            color: var(--text-primary);
        }

        ::-webkit-scrollbar { width: 8px; height: 8px; }
        ::-webkit-scrollbar-track { background: var(--bg-card); }
        ::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 4px; }
        ::-webkit-scrollbar-thumb:hover { background: #555; }

        .sidebar {
            display: flex;
            flex-direction: column;
            width: var(--sidebar-width);
            background: var(--bg-card);
            border-right: 1px solid var(--border-color);
            box-shadow: 0 0 20px rgba(0,0,0,0.5);
            z-index: 10;
        }

        .header {
            display: flex;
            align-items: center;
            flex-shrink: 0;
            gap: 12px;
            padding: 20px;
            border-bottom: 1px solid var(--border-color);
        }

        .header i { font-size: 1.8rem; color: var(--primary-color); }
        .header h1 {
            font-size: 1.4rem;
            font-weight: 700;
            background: linear-gradient(135deg, var(--primary-color), var(--success-color));
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }

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

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

        .label-row {
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-bottom: 10px;
            color: var(--text-secondary);
            font-size: 0.9rem;
            font-weight: 500;
        }

        .label-row i { margin-right: 8px; color: var(--primary-color); }

        .switch-container {
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 12px 16px;
            background: rgba(255, 255, 255, 0.02);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            margin-bottom: 20px;
        }

        .switch-title {
            font-size: 0.9rem;
            font-weight: 600;
            color: var(--text-primary);
        }

        .slide-switch {
            position: relative;
            display: flex;
            width: 140px;
            height: 36px;
            background: #0d1117;
            border: 1px solid var(--border-color);
            border-radius: 20px;
            cursor: pointer;
            user-select: none;
            overflow: hidden;
        }

        .slide-switch .switch-option {
            flex: 1;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.85rem;
            font-weight: bold;
            color: var(--text-secondary);
            z-index: 2;
            transition: color 0.25s ease;
        }

        .slide-switch .switch-slider {
            position: absolute;
            top: 3px;
            left: 3px;
            width: 65px;
            height: 28px;
            background: var(--primary-color);
            border-radius: 16px;
            z-index: 1;
            transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
            box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
        }

        .slide-switch.active .switch-slider { transform: translateX(67px); }
        .slide-switch.active .opt-right { color: #ffffff; }
        .slide-switch:not(.active) .opt-left { color: #ffffff; }
        #modeToggle .switch-slider { background: linear-gradient(135deg, var(--primary-color), var(--success-color)); }

        .value-badge {
            padding: 2px 8px;
            background: var(--primary-color);
            color: white;
            font-size: 0.8rem;
            font-weight: bold;
            border-radius: 10px;
        }

        .count-badge {
            margin-left: 5px;
            color: var(--success-color);
            font-size: 0.8rem;
            font-weight: normal;
        }

        .textarea-container { position: relative; width: 100%; }

        textarea.form-control, input.form-control, select.form-control {
            position: relative;
            z-index: 1;
            width: 100%;
            padding: 12px;
            background: var(--bg-input);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            color: var(--text-primary);
            font-family: 'Consolas', monospace;
            outline: none;
            transition: all 0.3s ease;
        }

        select.form-control { height: 42px; font-family: 'Inter', 'Noto Sans TC', sans-serif; cursor: pointer; }

        textarea.form-control {
            height: 250px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
            resize: vertical;
        }

        .data-textarea-bgtext {
            position: absolute;
            top: 14px;
            right: 14px;
            left: 14px;
            z-index: 2;
            display: block;
            color: #565c64;
            font-size: 0.85rem;
            font-family: 'Inter', 'Noto Sans TC', sans-serif;
            line-height: 1.6;
            pointer-events: none;
            transition: opacity 0.2s;
        }

        textarea.form-control:focus, input.form-control:focus {
            border-color: var(--primary-color);
            box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.2);
        }

        .textarea-toolbar {
            display: flex;
            overflow: hidden;
            gap: 1px;
            padding-top: 1px;
            background: var(--border-color);
            border-bottom-right-radius: 10px;
            border-bottom-left-radius: 10px;
        }

        .tool-btn {
            display: flex;
            flex: 1;
            align-items: center;
            justify-content: center;
            gap: 6px;
            padding: 10px;
            background: var(--bg-input);
            color: var(--text-secondary);
            font-size: 0.85rem;
            border: none;
            cursor: pointer;
            transition: all 0.2s;
        }

        .tool-btn:hover { background: rgba(255, 255, 255, 0.05); color: var(--text-primary); }
        #btnImport:hover { color: var(--primary-color); }
        #btnPaste:hover { color: var(--success-color); }
        #btnClear:hover { color: var(--danger-color); background: rgba(255, 82, 82, 0.1); }

        .validation-warning {
            display: none;
            align-items: center;
            gap: 10px;
            margin-top: 8px;
            padding: 10px 12px;
            color: #ffcccc;
            font-size: 0.85rem;
            line-height: 1.4;
            background: rgba(255, 82, 82, 0.15);
            border-left: 3px solid var(--danger-color);
            border-radius: 4px;
        }
        .validation-warning i { font-size: 1rem; flex-shrink: 0; }

        input[type=range] { width: 100%; margin: 10px 0; background: transparent; -webkit-appearance: none; }
        input[type=range]::-webkit-slider-thumb { width: 18px; height: 18px; margin-top: -7px; background: var(--primary-color); border-radius: 50%; box-shadow: 0 2px 6px rgba(0,0,0,0.3); cursor: pointer; -webkit-appearance: none; }
        input[type=range]::-webkit-slider-runnable-track { width: 100%; height: 4px; background: var(--border-color); border-radius: 2px; }

        .expand-btn {
            width: 100%; padding: 12px; background: var(--bg-input); border: 1px dashed var(--border-color);
            border-radius: 8px; color: var(--text-secondary); cursor: pointer; display: flex; align-items: center;
            justify-content: center; gap: 8px; transition: all 0.3s ease; margin-bottom: 20px; font-weight: 500;
        }
        .expand-btn:hover { border-color: var(--primary-color); color: var(--primary-color); }
        .expand-btn i { transition: transform 0.3s ease; }
        .expand-btn.expanded i { transform: rotate(180deg); }

        .advanced-settings { display: none; animation: slideDown 0.3s ease; }
        .advanced-settings.show { display: block; }
        @keyframes slideDown { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

        .settings-group { background: rgba(255, 255, 255, 0.03); border-radius: 10px; padding: 16px; margin-bottom: 16px; border: 1px solid var(--border-color); }
        .settings-group-title { font-size: 0.85rem; font-weight: 600; color: var(--primary-color); margin-bottom: 15px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px; }
        .control-row { display: flex; align-items: center; gap: 10px; margin-bottom: 15px; }
        .control-row:last-child { margin-bottom: 0; }

        .btn-group-toggle { display: flex; gap: 4px; background: var(--bg-input); padding: 4px; border-radius: 8px; border: 1px solid var(--border-color); }
        .btn-toggle-small { padding: 6px 12px; background: transparent; border: none; border-radius: 6px; color: var(--text-secondary); cursor: pointer; font-size: 0.85rem; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
        .btn-toggle-small:hover { color: var(--text-primary); background: rgba(255,255,255,0.05); }
        .btn-toggle-small.active { background: var(--primary-color); color: white; box-shadow: 0 2px 5px rgba(0, 168, 232, 0.3); }

        .btn-toggle { width: 46px; height: 42px; display: flex; align-items: center; justify-content: center; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px; color: var(--text-secondary); cursor: pointer; font-weight: 700; font-size: 1.1rem; transition: all 0.2s; flex-shrink: 0; }
        .btn-toggle:hover { border-color: var(--primary-color); color: var(--text-primary); }
        .btn-toggle.active { background: var(--primary-color); border-color: var(--primary-color); color: white; box-shadow: 0 0 10px rgba(0, 168, 232, 0.3); }

        .switch { position: relative; display: inline-flex; width: 44px; height: 24px; vertical-align: middle; }
        .switch input { opacity: 0; width: 0; height: 0; }
        .slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: var(--border-color); transition: .4s; border-radius: 24px; }
        .slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: white; transition: .4s; border-radius: 50%; }
        input:checked + .slider { background-color: var(--primary-color); }
        input:checked + .slider:before { transform: translateX(20px); }

        .footer-actions { flex-shrink: 0; padding: 20px; background: var(--bg-card); border-top: 1px solid var(--border-color); overflow: hidden; }
        .btn-primary { float: left; margin-right: 12px; width: calc(100% - 112px); display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; background: linear-gradient(135deg, var(--primary-color), var(--primary-dark)); color: white; font-size: 1rem; font-weight: 600; border: none; border-radius: 10px; box-shadow: 0 4px 15px rgba(0, 168, 232, 0.3); cursor: pointer; transition: transform 0.2s; }
        .btn-primary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 168, 232, 0.4); }
        .btn-primary:disabled { background: var(--bg-input); color: var(--text-secondary); box-shadow: none; cursor: not-allowed; }

        .btn-secondary { float: left; width: 100px; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 14px; background: linear-gradient(135deg, var(--success-color), #00a86b); color: white; font-size: 1rem; font-weight: 600; border: none; border-radius: 10px; box-shadow: 0 4px 15px rgba(0, 200, 83, 0.22); cursor: pointer; transition: transform 0.2s; }
        .btn-secondary:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 200, 83, 0.32); }
        .btn-secondary:disabled { background: var(--bg-input); color: var(--text-secondary); box-shadow: none; cursor: not-allowed; }

        .preview-area { display: flex; flex: 1; align-items: flex-start; justify-content: center; padding: 40px; background: #0d1117; background-image: linear-gradient(rgba(48, 54, 61, 0.3) 1px, transparent 1px), linear-gradient(90deg, rgba(48, 54, 61, 0.3) 1px, transparent 1px); background-size: 20px 20px; overflow: auto; }
        .preview-content { display: flex; flex-wrap: wrap; gap: 20px; justify-content: center; width: 100%; }

        .empty-state { margin-top: 100px; color: #8b949e; text-align: center; animation: breathe 3s infinite ease-in-out; }
        .empty-state i { display: block; margin-bottom: 25px; font-size: 5rem; opacity: 0.5; }
        .empty-state p { font-size: 1.5rem; font-weight: 300; letter-spacing: 1px; }

        @keyframes breathe { 0%, 100% { transform: scale(1); opacity: 0.6; } 50% { transform: scale(1.02); opacity: 1; } }

        .a4-page { width: 297mm; height: 210mm; background: white; position: relative; box-shadow: 0 0 50px rgba(0,0,0,0.5); display: flex; flex-direction: column; justify-content: center; align-items: center; box-sizing: border-box; padding: 20px; zoom: 0.6; }
        .a4-page svg { max-width: 100%; height: auto; display: block; overflow: visible; }
        .additional-text { font-family: 'Inter', 'Noto Sans TC', sans-serif; color: #000; text-align: center; line-height: 1.2; width: 100%; }
        .page-badge { position: absolute; top: -30px; left: 0; background: var(--bg-input); color: var(--text-secondary); padding: 4px 12px; border-radius: 4px; font-size: 14px; border: 1px solid var(--border-color); }

        .label-box { display: flex; flex-direction: column; width: 50mm; height: 30mm; box-sizing: border-box; border: 2px solid #000; background-color: #ffffff !important; font-family: "Malgun Gothic", Arial, sans-serif !important; overflow: hidden; }
        .label-top { display: flex; align-items: center; justify-content: center; height: 21%; font-size: 14pt; font-weight: bold; color: #000000 !important; background-color: #ffffff !important; }
        .label-barcode { display: flex; align-items: center; justify-content: center; height: 48%; padding: 2px 2mm; background-color: #ffffff !important; }
        .label-barcode svg { display: block; max-width: 100%; max-height: 100%; }
        .label-bottom { display: flex; align-items: center; justify-content: center; height: 31%; font-size: 20pt; font-weight: bold; letter-spacing: 1px; color: #ffffff !important; background-color: #000000 !important; font-family: "Cambria", serif !important; }

        @media print {
            body { display: block; height: auto; margin: 0; overflow: visible; background: white; }
            .sidebar { display: none !important; }
            .preview-area { display: block; padding: 0; overflow: visible; background: none; }
            .preview-content { display: block; gap: 0; margin: 0; padding: 0; }
        }

        .app-panel { width: 100%; }

        .scan-app, .scan-display {
            width: min(1100px, 100%);
            display: flex;
            gap: 20px;
            align-items: flex-start;
        }

        .scan-panel {
            background: var(--bg-card);
            border: 1px solid var(--border-color);
            border-radius: 12px;
            padding: 16px;
            min-width: 0;
        }

        .scan-panel-left { flex: 1 1 640px; }
        .scan-panel-right { flex: 0 0 380px; }
        .scan-display-camera { flex: 1 1 640px; }
        .scan-display-list { flex: 0 0 380px; }
        #scanPanel.no-camera .scan-display-list { flex: 1 1 auto; width: 100%; }

        #camera-section {
            position: relative;
            width: 100%;
            height: 320px;
            background: #000;
            border-radius: 12px;
            overflow: hidden;
            display: none;
            border: 1px solid var(--border-color);
        }
        #interactive { width: 100%; height: 100%; }
        #interactive video { width: 100% !important; height: 100% !important; object-fit: cover; display: block; }
        #interactive canvas { display: none; }

        .scan-frame-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
        .scan-frame { position: relative; width: 260px; height: 130px; }
        .scan-frame::before, .scan-frame::after { content: ''; position: absolute; width: 24px; height: 24px; border-color: var(--success-color); border-style: solid; }
        .scan-frame::before { top: 0; left: 0; border-width: 3px 0 0 3px; border-radius: 4px 0 0 0; }
        .scan-frame::after { top: 0; right: 0; border-width: 3px 3px 0 0; border-radius: 0 4px 0 0; }
        .corner-bl, .corner-br { position: absolute; width: 24px; height: 24px; border-color: var(--success-color); border-style: solid; }
        .corner-bl { bottom: 0; left: 0; border-width: 0 0 3px 3px; border-radius: 0 0 0 4px; }
        .corner-br { bottom: 0; right: 0; border-width: 0 3px 3px 0; border-radius: 0 0 4px 0; }
        .scan-line { position: absolute; left: 12px; right: 12px; height: 2px; background: linear-gradient(90deg, transparent, var(--success-color), transparent); animation: scanMove 1.8s ease-in-out infinite; }
        .scan-line.paused { animation-play-state: paused; opacity: 0.3; }
        @keyframes scanMove { 0% { top: 12px; opacity: 0; } 10% { opacity: 1; } 90% { opacity: 1; } 100% { top: calc(100% - 12px); opacity: 0; } }

        #pause-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.65); display: none; align-items: center; justify-content: center; z-index: 10; }
        #pause-overlay.show { display: flex; }
        .pause-text { color: #fff; font-size: 18px; font-weight: 600; }
        .scan-hint { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; font-size: 12px; color: rgba(255,255,255,0.75); z-index: 5; }

        #status-bar {
            font-size: 13px;
            color: var(--text-secondary);
            text-align: center;
            padding: 10px 12px;
            background: rgba(255, 255, 255, 0.03);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            min-height: 40px;
            display: flex;
            align-items: center;
            justify-content: center;
        }
        #status-bar.ok { color: var(--success-color); border-color: rgba(0, 200, 83, 0.3); }
        #status-bar.err { color: var(--danger-color); border-color: rgba(255, 82, 82, 0.3); }
        #status-bar.dup { color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }
        #status-bar.pause { color: #fbbf24; border-color: rgba(251, 191, 36, 0.3); }

        .scan-btn {
            width: 100%;
            padding: 13px;
            border-radius: 12px;
            border: 1px solid var(--border-color);
            font-size: 15px;
            font-weight: 700;
            cursor: pointer;
            background: linear-gradient(135deg, var(--success-color), var(--primary-color));
            color: #0d1117;
            display: flex;
            align-items: center;
            justify-content: center;
            gap: 8px;
        }
        .scan-btn:active { opacity: 0.85; }

        .scan-controls { display: none; gap: 10px; }
        .scan-controls.show { display: flex; }
        .scan-controls .tool-btn { flex: 1; border: 1px solid var(--border-color); border-radius: 10px; }

        .scan-divider { height: 1px; background: var(--border-color); opacity: 0.8; margin: 4px 0; }

        .scan-row { display: flex; gap: 10px; }
        .scan-row .tool-btn { flex: 1; border: 1px solid var(--border-color); border-radius: 10px; }

        .manual-row { display: flex; gap: 10px; }
        .manual-row input {
            flex: 1;
            padding: 12px;
            background: var(--bg-input);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            color: var(--text-primary);
            font-size: 14px;
            font-family: 'Consolas', monospace;
            outline: none;
        }
        .manual-row input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 3px rgba(0, 168, 232, 0.2); }
        .manual-row button {
            padding: 12px 14px;
            background: var(--bg-input);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            color: var(--text-primary);
            font-size: 14px;
            cursor: pointer;
            white-space: nowrap;
            font-family: 'Inter', 'Noto Sans TC', sans-serif;
        }

        .list-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
        .list-title { font-size: 0.9rem; color: var(--text-secondary); font-weight: 600; }
        #count-badge {
            font-size: 0.8rem;
            color: var(--primary-color);
            padding: 2px 10px;
            border-radius: 999px;
            border: 1px solid rgba(0, 168, 232, 0.3);
            background: rgba(0, 168, 232, 0.08);
        }

        #code-list { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; max-height: calc(100vh - 220px); padding-right: 2px; }
        .code-item { display: flex; align-items: center; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); border-radius: 10px; padding: 10px 12px; gap: 10px; }
        .code-num { font-size: 12px; color: var(--text-secondary); min-width: 22px; text-align: right; font-family: 'Consolas', monospace; }
        .code-text { font-size: 14px; color: var(--text-primary); flex: 1; font-family: 'Consolas', monospace; }
        .code-time { font-size: 12px; color: var(--text-secondary); font-family: 'Consolas', monospace; }
        .del-btn { background: none; border: none; cursor: pointer; color: var(--text-secondary); font-size: 20px; line-height: 1; padding: 0 2px; }
        .del-btn:active { color: var(--danger-color); }
        #empty-state { text-align: center; color: var(--text-secondary); font-size: 14px; padding: 2rem 0; }

        @media (max-width: 860px) {
            .scan-app, .scan-display { flex-direction: column; }
            .scan-panel-right, .scan-display-list { flex: 1 1 auto; width: 100%; }
            #camera-section { height: 260px; }
            #code-list { max-height: 260px; }
        }
