/* --- Scanner layout --- */
.page-head { margin-bottom: 14px; }
.page-head .page-lead { margin-bottom: 0; min-height: 1.2em; }

.scanner-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: 18px;
    align-items: start;
}

.col-side { position: sticky; top: 120px; }

@media (max-width: 900px) {
    .scanner-grid { grid-template-columns: 1fr; }
    .col-side { position: static; }
}

/* --- Lane panel: status text for the light in the top bar --- */
.lane-panel {
    --tone: 74, 222, 128;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 16px 20px;
    margin-bottom: 18px;
    border-radius: var(--radius-lg);
    color: #fff;
    background: linear-gradient(135deg, #16191e, #1e2229);
    border: 1px solid rgba(var(--tone), 0.35);
    box-shadow: var(--shadow), 0 0 36px -14px rgba(var(--tone), 0.8);
    transition: border-color 0.9s ease, box-shadow 0.9s ease;
}

.lane-panel[data-state="red"] { --tone: 248, 113, 113; }

.lane-dot {
    flex: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: rgb(var(--tone));
    box-shadow: 0 0 12px 2px rgba(var(--tone), 0.8);
    transition: background 0.9s ease, box-shadow 0.9s ease;
}

.lane-text { flex: 1; min-width: 0; }
/* The dot sits on the title's line, so it lines up with or without a second line. */
.lane-head { display: flex; align-items: center; gap: 14px; }
.lane-sub:empty { display: none; }
.lane-title { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.01em; }
.lane-sub { margin: 2px 0 0 28px; color: rgba(255, 255, 255, 0.78); font-size: 0.92rem; }

.lane-till { display: flex; flex-direction: column; gap: 6px; min-width: 190px; }
.lane-till label {
    font-size: 0.7rem; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}
.lane-till .form-control { min-height: 38px; }
.lane-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.lane-conn {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 0.75rem; font-weight: 650; color: rgba(255, 255, 255, 0.7);
}
.lane-conn:not(:empty)::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #f59e0b; }
.lane-conn[data-ok="true"]::before { background: #4ade80; box-shadow: 0 0 8px #4ade80; }

.light-test {
    min-height: 30px;
    padding: 4px 11px;
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.25);
    box-shadow: none;
}
.light-test:hover:not(:disabled) { background: rgba(255, 255, 255, 0.18); }

@media (max-width: 640px) {
    .lane-panel { flex-wrap: wrap; gap: 12px; padding: 14px 16px; }
    .lane-till { width: 100%; }
}

/* --- Attendant panel --- */
.attendant {
    border: 1px solid rgba(220, 38, 38, 0.45);
    box-shadow: var(--shadow), 0 0 0 4px rgba(220, 38, 38, 0.12);
    animation: attendant-in 0.35s cubic-bezier(0.2, 0.9, 0.3, 1.1);
}

.attendant:focus { outline: none; }
.attendant h3 { color: #b91c1c; font-size: 1.15rem; margin-bottom: 4px; }
.attendant-message { margin-bottom: 10px; color: var(--ink-soft); }

.attendant-details {
    display: inline-grid;
    grid-template-columns: auto auto;
    gap: 4px 16px;
    margin-bottom: 14px;
    padding: 10px 14px;
    border-radius: 10px;
    background: var(--danger-soft);
    font-size: 0.92rem;
}

.attendant-details:empty { display: none; }
.attendant-details dt { color: #7f1d1d; }
.attendant-details dd { font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }
.attendant fieldset { border: none; margin-bottom: 10px; }
.attendant legend { font-weight: 700; margin-bottom: 8px; }

.outcomes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
@media (max-width: 640px) { .outcomes { grid-template-columns: 1fr; } }

.outcome {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.outcome:hover { border-color: #b8c7e6; }
.outcome:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.outcome input { margin-top: 3px; accent-color: var(--primary); }
.outcome span { display: flex; flex-direction: column; gap: 2px; }
.outcome small { color: var(--muted); font-size: 0.8rem; }

@keyframes attendant-in {
    from { opacity: 0; transform: translateY(-6px) scale(0.99); }
    to { opacity: 1; transform: none; }
}

/* Locked lane: everything but the attendant is dimmed and disabled */
.scanner-grid { transition: opacity 0.4s ease, filter 0.4s ease; }
.lane-locked .scanner-grid { opacity: 0.45; filter: grayscale(0.4); pointer-events: none; }

/* --- Quick baskets --- */
.quick-basket-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.quick-basket {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-height: 64px;
    padding: 10px 12px;
    text-align: left;
    border-radius: 12px;
    background: linear-gradient(180deg, #fff, var(--surface-2));
}

.quick-basket:hover:not(:disabled) { border-color: #9db6ea; }
.quick-name { font-weight: 750; }
.quick-hint { font-weight: 500; font-size: 0.78rem; color: var(--muted); }

.weight-basket { margin-top: 18px; padding-top: 16px; border-top: 1px dashed var(--line); }
.weight-basket label { display: flex; align-items: baseline; justify-content: space-between; font-weight: 700; margin-bottom: 8px; }
#weight-value { font-variant-numeric: tabular-nums; font-weight: 800; font-size: 1.1rem; color: var(--primary-dark); }
.weight-row { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.weight-row input[type="range"] { flex: 1; accent-color: var(--primary); height: 28px; }

/* --- Scan --- */
.manual-input { display: flex; gap: 8px; margin-bottom: 10px; }
.manual-input .form-control { font-family: var(--mono); letter-spacing: 0.04em; }
.camera-btn { background: var(--surface-2); }

.video-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4/3;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    margin-top: 12px;
}

.video-container video { width: 100%; height: 100%; object-fit: cover; }

.scan-overlay {
    position: absolute;
    left: 10%;
    right: 10%;
    height: 3px;
    background: rgba(248, 113, 113, 0.85);
    box-shadow: 0 0 12px rgba(248, 113, 113, 0.9);
    animation: scanLine 2s ease-in-out infinite;
}

@keyframes scanLine {
    0%, 100% { top: 35%; }
    50% { top: 65%; }
}

/* --- Cart --- */
.cart-list { display: flex; flex-direction: column; }

.cart-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--line);
    animation: page-in 0.25s ease both;
}

.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cart-item-ean { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.cart-item-weight { font-size: 0.8rem; color: var(--muted); }

.cart-item-actions { display: flex; align-items: center; gap: 4px; }

.qty-btn, .remove-btn {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1px solid var(--line);
    background: #fff;
    font-size: 1rem;
    font-weight: 700;
    color: var(--ink);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.qty-btn:hover:not(:disabled) { background: var(--surface-2); border-color: #b8c7e6; }
.remove-btn { color: #b91c1c; margin-left: 4px; }
.remove-btn:hover:not(:disabled) { background: var(--danger-soft); border-color: #f5b5b5; }
.qty-value { min-width: 26px; text-align: center; font-weight: 750; font-variant-numeric: tabular-nums; }

.cart-empty { text-align: center; color: var(--muted); padding: 22px 8px; border: 1px dashed var(--line); border-radius: 12px; }

.cart-total {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--surface-2);
    font-weight: 750;
    font-variant-numeric: tabular-nums;
    text-align: right;
}

.checkout-section { margin-top: 16px; }
.checkout-btn { min-height: 52px; font-size: 1.08rem; border-radius: 12px; }

.checkout-result {
    margin-top: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    font-weight: 600;
    line-height: 1.5;
    animation: page-in 0.3s ease both;
}

.checkout-result.success { background: var(--success-soft); color: #14532d; }
.checkout-result.error { background: var(--danger-soft); color: #7f1d1d; }

/* --- Phones --- */
.mobile-checkout { display: none; }

@media (max-width: 900px) {
    /* Flatten the two columns so the cart can sit right after the quick baskets */
    .scanner-grid { display: flex; flex-direction: column; gap: 0; }
    .col-main, .col-side { display: contents; }
    .quick-baskets { order: 1; }
    .cart { order: 2; }
    .scanner-section { order: 3; }
}

@media (max-width: 720px) {
    .lane-title { font-size: 1.1rem; }
    .lane-panel { position: relative; }
    .lane-tools { justify-content: space-between; }

    .quick-basket-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .quick-basket { min-height: 58px; padding: 9px 10px; }

    .qty-btn, .remove-btn { width: 38px; height: 38px; font-size: 1.1rem; }
    .cart-item { flex-wrap: wrap; }
    .cart-item-info { flex-basis: 100%; }
    .cart-item-actions { margin-left: auto; }

    .manual-input .btn { min-width: 76px; }
    .attendant-details { display: grid; }

    /* The page's own Checkout is replaced by the sticky bar */
    .checkout-section .checkout-btn { display: none; }

    .mobile-checkout {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: calc(78px + env(safe-area-inset-bottom));
        z-index: 140;
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 10px 10px 10px 16px;
        border-radius: 16px;
        color: #fff;
        background: rgba(24, 27, 32, 0.97);
        border: 1px solid rgba(255, 255, 255, 0.14);
        box-shadow: 0 16px 34px -12px rgba(0, 0, 0, 0.7);
        animation: page-in 0.25s ease both;
    }

    .mobile-checkout.hidden { display: none !important; }
    .mobile-checkout-text { flex: 1; font-weight: 700; font-variant-numeric: tabular-nums; }
    .mobile-checkout .btn { min-width: 128px; min-height: 46px; }
    .lane-locked .mobile-checkout { opacity: 0.5; }

    /* Make room for the sticky bar above the tab bar */
    .scanner-page { padding-bottom: 76px; }
}

/* --- Attendant panel: touch-screen sized (a staff member taps it on the till) --- */
.attendant { padding: 24px; }
.attendant h3 { font-size: 1.5rem; margin-bottom: 6px; }
.attendant-message { font-size: 1.1rem; margin-bottom: 14px; }
.attendant-details { font-size: 1.1rem; padding: 12px 18px; gap: 6px 22px; }
.attendant legend { font-size: 1.15rem; margin-bottom: 12px; }

.outcomes { gap: 12px; }

.outcome {
    position: relative;
    align-items: center;
    gap: 16px;
    min-height: 104px;
    padding: 18px 20px;
    border-width: 2px;
    border-radius: 16px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.outcome input {
    flex: none;
    width: 26px;
    height: 26px;
    margin: 0;
}

.outcome-body { display: flex; flex-direction: column; gap: 3px; }
.outcome strong { font-size: 1.2rem; }
.outcome small { font-size: 0.95rem; }
.outcome:active { transform: scale(0.99); }

.outcome-tag {
    align-self: flex-start;
    margin-bottom: 2px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.outcome-fp .outcome-tag { color: #1e3a8a; background: #dbeafe; }
.outcome-tp .outcome-tag { color: #7f1d1d; background: #fee2e2; }
.outcome-tp:has(input:checked) { border-color: #dc2626; background: #fff1f1; box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.15); }
.outcome-tp input { accent-color: #dc2626; }

.attendant .form-group label { font-size: 1rem; }
.attendant textarea.form-control { font-size: 1.05rem; min-height: 72px; }

.resolve-btn { min-height: 64px; font-size: 1.25rem; border-radius: 14px; }

@media (max-width: 640px) {
    .attendant { padding: 18px; }
    .attendant h3 { font-size: 1.25rem; }
    .outcome { min-height: 88px; padding: 14px 16px; }
    .outcome strong { font-size: 1.1rem; }
}

/* --- Till picker: radio buttons as pills --- */
.lane-till { min-width: 0; max-width: 460px; }
.till-picker { border: none; }
.till-picker legend {
    margin-bottom: 6px;
    font-size: 0.7rem; font-weight: 750; letter-spacing: 0.1em; text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
}
.till-options { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }

.till-option { position: relative; cursor: pointer; }
.till-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.till-option span {
    display: inline-flex;
    align-items: center;
    min-height: 38px;
    padding: 7px 16px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.92rem;
    font-family: var(--mono);
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.4s;
}
.till-option:hover span { background: rgba(255, 255, 255, 0.13); }
.till-option input:checked + span {
    color: #10141a;
    background: #fff;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(var(--tone), 0.35), 0 0 16px -2px rgba(var(--tone), 0.8);
}
.till-option input:focus-visible + span { outline: 3px solid #93c5fd; outline-offset: 2px; }
.till-empty { font-size: 0.85rem; color: rgba(255, 255, 255, 0.7); }

@media (max-width: 720px) {
    .lane-till { max-width: none; }
    .till-options { justify-content: flex-start; }
    .till-option span { min-height: 44px; padding: 9px 18px; font-size: 1rem; }
}

/* Weighed (per kg) cart lines and the weigh dialog */
.cart-item-weight .kg-tag {
    display: inline-block;
    margin-right: 4px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 0.7rem;
    font-weight: 700;
}
.weigh-row { display: flex; gap: 8px; align-items: stretch; }
.weigh-row .form-control { flex: 1; font-size: 1.25rem; font-family: var(--mono); }
.weigh-price { color: var(--muted); margin-bottom: 12px; }
.weigh-error { color: var(--danger); font-size: 0.85rem; min-height: 1.2em; margin-top: 6px; }
