:root {
    --bg-color: #f6f8fa;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --primary: #4f46e5;
    --success: #10b981;
    --danger: #ef4444;
    --border-radius: 16px;
}

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    margin: 0;
    padding: 16px;
    padding-bottom: 100px;
}

.app-container { max-width: 500px; margin: 0 auto; }

header { margin-bottom: 24px; }
header h1 { margin: 0; font-size: 1.8rem; font-weight: 800; }
header p { margin: 4px 0 0; color: #64748b; font-size: 0.95rem; }

/* Plus Button (FAB) */
.fab-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 2.2rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 10px 15px -3px rgba(79, 70, 229, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99;
}

/* Produktliste */
.grid-list { display: flex; flex-direction: column; gap: 12px; }

.product-item {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 16px;
    border: 2px solid transparent;
}

.product-item img { width: 50px; height: 50px; object-fit: contain; border-radius: 8px; background: #f8fafc; }
.product-info { flex: 1; }
.product-info h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.product-info p { margin: 4px 0 0; font-size: 0.85rem; color: #64748b; }
.product-info .mhd-badge { display: inline-block; margin-top: 6px; font-weight: 700; font-size: 0.85rem; }

/* DAUERHAFTE ROTE WARNUNG */
.product-item.expired {
    border-color: var(--danger) !important;
    background-color: #fef2f2 !important;
}
.product-item.expired .mhd-badge { color: var(--danger); }

/* POPUP / MODAL */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.6);
    display: none; 
    align-items: flex-end; 
    z-index: 100;
}
.modal-overlay.open { 
    display: flex !important; 
}

.modal-content {
    background: var(--card-bg);
    width: 100%;
    max-height: 90vh;
    border-top-left-radius: 24px;
    border-top-right-radius: 24px;
    padding: 24px;
    overflow-y: auto;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.modal-header h2 { margin: 0; font-size: 1.2rem; }
.close-btn { background: #f1f5f9; border: none; font-size: 1.5rem; width: 36px; height: 36px; border-radius: 50%; cursor: pointer; }

/* Schritte-Regelung */
.wizard-step { display: none !important; }
.wizard-step.active { display: block !important; }

/* Barcode-Reader Container */
#barcode-reader {
    position: relative; /* Wichtig für die Positionierung unseres Suchers */
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    margin-bottom: 15px;
}

/* Zielbox-Overlay für die Kameras (MHD) */
.camera-wrapper {
    position: relative;
    width: 100%;
    background: #000;
    border-radius: var(--border-radius);
    overflow: hidden;
    aspect-ratio: 4/3;
    margin-bottom: 15px;
}

/* REPARATUR: Spricht das echte Video-Element im Barcode-Reader UND der MHD-Kamera an */
#barcode-reader video, #ocr-video { 
    width: 100% !important; 
    height: 100% !important; 
    object-fit: cover !important; 
}

/* Der rote Sucher-Rahmen in der Mitte */
.scan-target-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%); /* Exakte mathematische Zentrierung */
    width: 280px;
    height: 100px;
    border: 3px solid #ef4444;
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5); /* Dunkelt den Rest perfekt ab */
    pointer-events: none;
    z-index: 10;
}

/* Animierte Laser-Linie */
.scan-laser {
    position: absolute;
    width: 100%;
    height: 2px;
    background-color: #ef4444;
    top: 50%;
    animation: laserMove 2s infinite ease-in-out;
}

@keyframes laserMove {
    0% { top: 5%; }
    50% { top: 95%; }
    100% { top: 5%; }
}

/* REPARATUR: Blendet den automatisch generierten, zweiten Kasten der Library aus */
#barcode-reader__scan_region, 
#barcode-reader__scan_region div,
#barcode-reader__scan_region fieldset {
    border: none !important;
}

.form-group { display: flex; flex-direction: column; margin-bottom: 12px; }
.input-with-btn { display: flex; gap: 8px; }
.input-with-btn input { flex: 1; }
input { padding: 12px; border: 1px solid #cbd5e1; border-radius: 10px; font-size: 1rem; }

.btn { background: var(--primary); color: white; border: none; padding: 12px 20px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.btn.success { background: var(--success); }
.btn.danger-link { background: transparent; color: var(--danger); border: none; font-size: 0.85rem; cursor: pointer; }
.btn.full-width { width: 100%; }
.mt-1 { margin-top: 12px; }

.product-preview-badge { display: flex; align-items: center; gap: 12px; background: #f1f5f9; padding: 12px; border-radius: 12px; margin-bottom: 16px; }
.product-preview-badge img { width: 40px; height: 40px; object-fit: contain; }
.status-text { font-size: 0.85rem; color: var(--primary); text-align: center; margin: 8px 0; }