:root {
    --ink: #10201d;
    --panel: #f7f8f4;
    --accent: #24745f;
    --accent-2: #d9a441;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--ink);
    color: #fff;
}

.app-shell {
    min-height: 100vh;
    padding: env(safe-area-inset-top) 14px env(safe-area-inset-bottom);
}

.login-view,
.session-view {
    min-height: 100dvh;
    display: grid;
    align-items: start;
    justify-items: center;
    padding-top: max(42px, env(safe-area-inset-top));
    padding-bottom: 20px;
}

.login-panel,
.session-panel {
    width: min(100%, 420px);
}

.login-panel h1,
.session-panel h1 {
    margin-bottom: 18px;
    font-size: 1.95rem;
    font-weight: 800;
    line-height: 1.08;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
}

.inventory-name {
    font-weight: 800;
    font-size: 1.15rem;
}

.inventory-stats,
.pending-line {
    color: rgba(255, 255, 255, .75);
    font-size: .95rem;
}

.scanner-box {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    max-height: 62vh;
    overflow: hidden;
    background: #050807;
    border-radius: 8px;
}

#scannerVideo {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-overlay {
    position: absolute;
    inset: 18%;
    border: 3px solid rgba(255, 255, 255, .9);
    border-radius: 8px;
    box-shadow: 0 0 0 999px rgba(0, 0, 0, .28);
}

.scanner-status {
    position: absolute;
    left: 12px;
    right: 12px;
    bottom: 12px;
    padding: 9px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, .65);
    font-weight: 700;
}

.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.scanner-view .controls-grid,
.mode-row,
.pending-line,
.recent-section {
    margin-top: 12px;
}

.btn-lg {
    min-height: 52px;
    font-weight: 700;
}

.recent-section h2,
.barcode-detail h3 {
    font-size: 1rem;
    margin: 0 0 8px;
    font-weight: 800;
}

.recent-list {
    display: grid;
    gap: 8px;
}

.recent-item,
.product-list-item {
    display: grid;
    grid-template-columns: 58px 1fr auto;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 8px;
    border: 0;
    border-radius: 8px;
    background: rgba(255, 255, 255, .1);
    color: #fff;
    text-align: left;
}

.recent-item img,
.product-list-item img {
    width: 58px;
    height: 58px;
    object-fit: cover;
    border-radius: 6px;
    background: rgba(255, 255, 255, .12);
}

.recent-title {
    font-weight: 800;
}

.recent-meta,
.product-list-meta {
    color: rgba(255, 255, 255, .72);
    font-size: .85rem;
    overflow-wrap: anywhere;
}

.recent-qty,
.product-list-qty {
    font-size: 1.15rem;
    font-weight: 900;
}

.products-list {
    display: grid;
    gap: 8px;
}

.product-list-item {
    background: #fff;
    color: #17231f;
    border: 1px solid #dfe5dc;
}

.product-list-meta {
    color: #65706a;
}

.product-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
}

.product-actions .btn {
    min-height: 52px;
}

.modal-content {
    color: #18221f;
    background: var(--panel);
}

.qty-control {
    display: grid;
    grid-template-columns: 64px 1fr 64px;
    gap: 8px;
}

.qty-control input {
    text-align: center;
    font-weight: 800;
}

.photo-row {
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #e5e9df;
    border-radius: 8px;
    display: grid;
    place-items: center;
    overflow: hidden;
}

.photo-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.photo-placeholder {
    color: #66706b;
    font-weight: 700;
    font-size: .85rem;
    text-align: center;
    padding: 6px;
}

.photo-compact {
    display: grid;
    grid-template-columns: 96px 1fr;
    align-items: stretch;
    gap: 10px;
}

.photo-compact .photo-row {
    width: 96px;
    height: 96px;
}

.photo-compact .btn {
    min-height: 96px;
}

.barcode-detail {
    padding-top: 8px;
    border-top: 1px solid #d9ded4;
}

.internal-code {
    font-size: 1.2rem;
    font-weight: 900;
    letter-spacing: 0;
}

#code128,
#printCode128 {
    width: 100%;
    max-height: 110px;
}

.qr-canvas {
    width: 160px;
    height: 160px;
}

.print-label {
    display: none;
}

@media (min-width: 700px) {
    .app-shell {
        max-width: 520px;
        margin: 0 auto;
    }
}

@media print {
    body * {
        visibility: hidden !important;
    }

    .print-label,
    .print-label * {
        visibility: visible !important;
    }

    .print-label {
        display: block;
        position: fixed;
        inset: 0;
        width: 70mm;
        min-height: 38mm;
        padding: 5mm;
        color: #000;
        background: #fff;
        text-align: center;
        font-family: Arial, sans-serif;
    }

    #printProductName {
        font-size: 12pt;
        font-weight: 700;
        margin-bottom: 2mm;
    }

    #printBarcodeText {
        font-size: 10pt;
        margin-top: 1mm;
    }
}
