:root {
    --primary: #3498db;
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --macro: #9b59b6;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #1a2a6c, #b21f1f, #fdbb2d);
    color: #333;
    line-height: 1.6;
    padding: 15px;
    min-height: 100vh;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.97);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: var(--dark);
    color: white;
    text-align: center;
    padding: 15px;
    border-bottom: 4px solid var(--primary);
}

h1 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.instructions {
    background: #f8f9fa;
    padding: 12px;
    border-radius: 8px;
    margin: 12px;
    border-left: 4px solid var(--primary);
    font-size: 0.9rem;
}

.instructions h3 {
    color: var(--dark);
    margin-bottom: 8px;
    font-size: 1rem;
}

.instructions ol {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 6px;
}

.camera-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
    overflow: hidden;
    background: #000;
    border-radius: 8px;
}

#video {
    width: 100%;
    display: block;
    transition: all 0.3s ease;
    border-radius: 8px;
}

.macro-controls {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
}

.btn-macro {
    padding: 8px 12px;
    border: none;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn-macro:hover {
    background: rgba(0, 0, 0, 0.9);
}

.btn-macro.active {
    background: var(--macro);
}

.macro-icon {
    font-size: 14px;
}

.scan-region {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 30%;
    border: 2px solid var(--success);
    border-radius: 8px;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.3);
    z-index: 5;
}

.scan-line {
    position: absolute;
    height: 2px;
    width: 100%;
    background: var(--success);
    top: 0;
    animation: scan 2s infinite linear;
}

@keyframes scan {
    0% { top: 0; }
    50% { top: calc(100% - 2px); }
    100% { top: 0; }
}

.controls {
    padding: 15px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    background: #f8f9fa;
    border-bottom: 1px solid #ddd;
}

.btn {
    padding: 12px 15px;
    border: none;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

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

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

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

.btn-macro-toggle {
    background: var(--macro);
    color: white;
    grid-column: span 2;
}

.btn-macro-toggle.active {
    background: #8e44ad;
    box-shadow: 0 0 10px rgba(142, 68, 173, 0.5);
}

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

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

.btn-download {
    background: var(--dark);
    color: white;
    grid-column: span 2;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.status {
    padding: 12px;
    text-align: center;
    font-weight: 600;
    background: #e8f4fc;
    border-bottom: 1px solid #bde0fe;
    font-size: 0.9rem;
}

.status.scanning {
    background: #fff3cd;
    border-color: #ffdf89;
}

.barcode-list-container {
    padding: 15px;
}

.barcode-list {
    list-style: none;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
}

.barcode-item {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eee;
    font-family: monospace;
    font-size: 0.9rem;
}

.barcode-item:last-child {
    border-bottom: none;
}

.barcode-value {
    font-weight: bold;
}

.barcode-time {
    color: #666;
    font-size: 0.8rem;
}

.batch-info {
    background: var(--dark);
    color: white;
    padding: 10px;
    text-align: center;
    font-size: 0.9rem;
    border-bottom: 1px solid #ddd;
}

footer {
    text-align: center;
    padding: 12px;
    background: #f8f9fa;
    color: #666;
    font-size: 0.8rem;
    border-top: 1px solid #ddd;
}

@media (max-width: 480px) {
    .controls {
        grid-template-columns: 1fr;
    }
    
    .btn-macro-toggle,
    .btn-download {
        grid-column: span 1;
    }
    
    .scan-region {
        width: 80%;
        height: 25%;
    }
}