*{margin:0;padding:0;box-sizing:border-box}
body{font-family:'Segoe UI',Tahoma,sans-serif;background:#f0f2f5;color:#222;min-height:100vh}
.app{max-width:560px;margin:0 auto;padding:16px 16px 40px}

header{text-align:center;padding:24px 0 16px}
header h1{font-size:1.6rem;color:#1a1a2e}
header p{color:#666;font-size:.88rem;margin-top:4px}

/* Cards */
.card{background:#fff;border-radius:12px;padding:20px;box-shadow:0 1px 4px rgba(0,0,0,.06);margin-bottom:16px}
.card.hidden{display:none}

/* Camera */
.camera-box{position:relative;width:100%;max-width:360px;height:240px;margin:0 auto 12px;border-radius:8px;overflow:hidden;background:#000}
.camera-box video{width:100%;height:100%;object-fit:cover}
.camera-box canvas{display:none}
.scan-line{display:none;position:absolute;left:10%;width:80%;height:2px;background:#0f0;box-shadow:0 0 8px #0f0;z-index:2;animation:scan 2s ease-in-out infinite}
.scanning .scan-line{display:block}
@keyframes scan{0%{top:10%}50%{top:85%}100%{top:10%}}

/* Center helpers */
.center{display:flex;justify-content:center;align-items:center}
.gap{gap:8px;flex-wrap:wrap}

/* Buttons */
.btn{padding:10px 22px;border:none;border-radius:8px;font-size:.92rem;cursor:pointer;background:#1a73e8;color:#fff;transition:background .15s}
.btn:hover{background:#1557b0}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn-outline{background:#fff;color:#555;border:1.5px solid #ddd}
.btn-outline:hover{border-color:#1a73e8;color:#1a73e8}

/* Input */
.input{padding:10px 14px;border:1.5px solid #ddd;border-radius:8px;font-size:.92rem;outline:none;flex:1;min-width:160px}
.input:focus{border-color:#1a73e8}

/* Divider */
.divider{display:flex;align-items:center;margin:14px 0;color:#999;font-size:.82rem}
.divider::before,.divider::after{content:'';flex:1;height:1px;background:#ddd}
.divider span{padding:0 16px}

.manual{display:flex;gap:8px}

/* Status */
.status{margin-top:8px;text-align:center;font-size:.85rem;min-height:20px}
.status.success{color:#0a0}
.status.error{color:#c00}
.status.info{color:#1a73e8}

/* Barcode badge */
.barcode-badge{background:#f2f2f2;padding:6px 14px;border-radius:6px;margin-bottom:16px;font-size:.88rem}
.barcode-badge .label{color:#666}
.barcode-badge .code{font-weight:700;font-family:'Courier New',monospace;letter-spacing:1px;margin-left:6px}

/* Product head */
.product-head{display:flex;gap:16px;margin-bottom:16px;flex-wrap:wrap}
.product-img{width:120px;height:120px;border-radius:8px;object-fit:contain;background:#f5f5f5;flex-shrink:0}
.product-head-text{flex:1;min-width:180px}
.product-head-text h2{font-size:1.2rem;margin-bottom:2px}
.brand{color:#1a73e8;font-weight:500;font-size:.9rem}
.qty{color:#666;font-size:.85rem;margin-top:2px}

/* Details grid */
.details-grid{display:grid;grid-template-columns:1fr 1fr;gap:8px;margin-bottom:16px}
.detail-item{background:#f8f8f8;padding:10px 12px;border-radius:8px}
.detail-label{font-size:.72rem;color:#888;display:block}
.detail-value{font-weight:600;font-size:.9rem;color:#333}

/* Ingredients */
#ingredientsBox{margin-bottom:16px}
#ingredientsBox h3{font-size:.95rem;margin-bottom:6px}
#ingredients{font-size:.85rem;line-height:1.6;color:#444}

/* Nutrients table */
#nutrientsBox h3{font-size:.95rem;margin-bottom:8px}
#nutrientsTable{width:100%;border-collapse:collapse;font-size:.85rem}
#nutrientsTable td{padding:5px 8px;border-bottom:1px solid #eee}
#nutrientsTable td:first-child{color:#555}
#nutrientsTable td:last-child{text-align:right;font-weight:600}

/* History */
#historySection h3{margin-bottom:12px}
#historyList{list-style:none}
#historyList li{display:flex;gap:8px;align-items:center;padding:10px 0;border-bottom:1px solid #eee;cursor:pointer}
#historyList li:hover{background:#f8f9ff}
#historyList .h-code{font-family:'Courier New',monospace;font-weight:700;white-space:nowrap}
#historyList .h-name{flex:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#555;font-size:.88rem}
#historyList .h-time{color:#aaa;font-size:.78rem;white-space:nowrap}

footer{text-align:center;color:#aaa;font-size:.75rem;padding:8px}

@media(max-width:420px){
    .details-grid{grid-template-columns:1fr}
    .product-head{flex-direction:column;align-items:center;text-align:center}
}
