/* ── Search header ───────────────────────────────── */
.search-header {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 200;
}

.search-wrap {
    flex: 1;
    position: relative;
}

/* ── Search filter toggles (in dropdown footer) ─────── */
.sf-group {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
}

.sf-btn {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 11px;
    transition: color .12s, background .12s;
    position: relative;
}

.sf-btn:hover {
    background: #f1f5f9;
    color: #64748b;
}

.sf-btn.active {
    background: rgba(72, 109, 180, .1);
    color: #5078FE;
}

.sf-btn.active::after {
    content: '';
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #5078FE;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f7f9fc;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    padding: 0 14px;
    height: 38px;
    transition: border-color .15s, box-shadow .15s, background .15s;
    cursor: text;
}

.search-box:focus-within {
    background: #fff;
    border-color: #5078FE;
    box-shadow: 0 0 0 3px rgba(72, 109, 180, .13);
}

.s-icon {
    color: #a0aec0;
    flex-shrink: 0;
}

#q {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: #1a202c;
    font-size: 16px;
}

#q::placeholder {
    color: #a0aec0;
}

.scan-btn {
    border: none;
    background: transparent;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 6px;
    color: #94a3b8;
    font-size: 14px;
    cursor: pointer;
    flex-shrink: 0;
    transition: color .12s, background .12s;
}

.scan-btn:hover {
    background: #f1f5f9;
    color: #5078FE;
}

.scan-btn.active {
    color: #5078FE;
}

/* scanning overlay */
.scan-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
}

.scan-overlay video {
    width: min(480px, 90vw);
    border-radius: 12px;
    display: block;
}

.scan-overlay .scan-frame {
    position: absolute;
    width: min(260px, 70vw);
    height: 80px;
    border: 2px solid #5078FE;
    border-radius: 6px;
    box-shadow: 0 0 0 2000px rgba(0, 0, 0, .4);
    pointer-events: none;
}

.scan-hint {
    color: #94a3b8;
    font-size: 13px;
}

.scan-cancel {
    color: #fff;
    font-size: 13px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, .3);
    border-radius: 8px;
    padding: 8px 20px;
    cursor: pointer;
    margin-top: 4px;
}

.scan-cancel:hover {
    background: rgba(255, 255, 255, .1);
}

.s-kbd {
    display: flex;
    gap: 3px;
    flex-shrink: 0;
}

kbd {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    padding: 1px 5px;
    font: inherit;
    font-size: 10px;
    color: #94a3b8;
    line-height: 15px;
}

/* ── Dropdown ────────────────────────────────────── */
#searchblock .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 10px 36px rgba(0, 0, 0, .11), 0 2px 8px rgba(0, 0, 0, .06);
    display: none;
    z-index: 999;
    overflow: hidden;
    max-width: 100%;
    line-height: initial;
}

#searchblock .dropdown.open {
    display: block;
}

/* mobile: span full width below the header bar */


/* 1 col default, 2 col when container wide enough */
.sec-grid {
    display: grid;
    grid-template-columns: 1fr;
    row-gap: 1px;
}


/* tabs */
.tabs {
    display: flex;
    flex-wrap: wrap;
    padding: 0 8px;
    border-bottom: 1px solid #f1f5f9;
    gap: 1px;
}

.tab {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 9px 10px 8px;
    font-size: 11.5px;
    font-weight: 600;
    color: #94a3b8;
    cursor: pointer;
    user-select: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .12s, border-color .12s;
    white-space: nowrap;
}

.tab:hover {
    color: #64748b;
}

.tab.active {
    color: #5078FE;
    border-bottom-color: #5078FE;
}

.tc {
    background: #f1f5f9;
    border-radius: 10px;
    padding: 0 5px;
    font-size: 10px;
    font-weight: 700;
    color: #94a3b8;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}

.tab.active .tc {
    background: rgba(72, 109, 180, .12);
    color: #5078FE;
}

/* results */
.results {
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 5px 0;
    container-type: inline-size;
}

.results::-webkit-scrollbar {
    width: 4px;
}

.results::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

/* category groups */
.sec-group {
}

.sec-group + .sec-group {
    border-top: 1.5px solid #e8ecf1;
    margin-top: 4px;
    padding-top: 2px;
}

.sec-label {
    padding: 10px 14px 4px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
}

/* result row */
.ri {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 14px;
    cursor: pointer;
    transition: background .08s;
    background: #fff;
    overflow: hidden;
    min-width: 0;
}

.ri:hover, .ri.focused {
    background: #f5f8ff;
}

.ri-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
    min-width: 0;
}

.ri-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ri-icon svg {
    display: block;
}

.ic-vehicle {
    background: #eff6ff;
    color: #3b82f6;
}

.ic-part {
    background: #fff7ed;
    color: #f97316;
}

.ic-task {
    background: #faf5ff;
    color: #8b5cf6;
}

.ic-note {
    background: #fffbeb;
    color: #d97706;
}

.ic-location {
    background: #f0fdf4;
    color: #16a34a;
}

.stock-tag {
    font-size: 10.5px;
    font-weight: 600;
    color: #94a3b8;
    margin-left: 4px;
    letter-spacing: .01em;
}

.vin-dim {
    color: #94a3b8;
}

.vin-hi {
    color: #64748b;
}

.vin-bold {
    color: #475569;
    font-weight: 700;
}

.ri-loc {
    color: #94a3b8;
    font-size: 10px;
    margin-right: 2px;
}

.ri-body {
    flex: 1;
    min-width: 0;
}

.ri-title {
    font-size: 12.5px;
    font-weight: 500;
    color: #1a202c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ri-title mark {
    background: transparent;
    color: #5078FE;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-color: rgba(72, 109, 180, .3);
    text-underline-offset: 2px;
}

.ri-meta {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 1px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 5px;
    line-height: initial;
}

.ri-meta-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sold-ref {
    color: #dc2626;
    font-size: 9px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    flex-shrink: 0;
    display: flex;
    min-height: 12px;
    align-items: center;
    justify-content: center;
}

.ri-thumb {
    width: 72px;
    height: 48px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: cover;
    object-position: center;
    background: #f1f5f9;
}

/* status pills */
.pill {
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
    flex-shrink: 0;
    display: flex;
    min-height: 16px;
    align-items: center;
}

.p-transit {
    background: #dbeafe;
    color: #1d4ed8;
}

.p-detail {
    background: #ede9fe;
    color: #6d28d9;
}

.p-arrival {
    background: #dcfce7;
    color: #15803d;
}

.p-ready {
    background: #d1fae5;
    color: #065f46;
}

.p-pending {
    background: #fef3c7;
    color: #92400e;
}

.p-inorder {
    background: #e0f2fe;
    color: #0369a1;
}

.p-received {
    background: #dcfce7;
    color: #15803d;
}

.p-inprog {
    background: #ede9fe;
    color: #6d28d9;
}

.p-start {
    background: #f1f5f9;
    color: #475569;
}

.p-note {
    background: #fef9c3;
    color: #854d0e;
}

.p-vendor {
    background: #f0fdf4;
    color: #15803d;
}

.p-auction {
    background: #fef3c7;
    color: #92400e;
}

.p-sold {
    background: #fee2e2;
    color: #dc2626;
}

/* vehicle type badge (Retail / Wholesale / Lease / Fleet) */
.ri-type {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: 1px 5px;
    border-radius: 3px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    min-height: 14px;
    justify-content: center;
}

.type-retail {
    background: #dbeafe;
    color: #1d4ed8;
}

.type-wholesale {
    background: #fef3c7;
    color: #92400e;
}

.type-lease {
    background: #ede9fe;
    color: #6d28d9;
}

.type-fleet {
    background: #d1fae5;
    color: #065f46;
}

/* vehicle label chips */
.ri-labels {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-top: 4px;
}

.ri-label {
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 0px 5px;
    border-radius: 3px;
    background: #f1f5f9;
    color: #475569;
    line-height: 14px;
    display: flex;
    min-height: 16px;
    align-items: center;
}

.lbl-new {
    background: #dcfce7;
    color: #15803d;
}

.lbl-asap {
    background: #fee2e2;
    color: #dc2626;
}

.lbl-trade {
    background: #fef3c7;
    color: #92400e;
}

.lbl-fleet {
    background: #e0f2fe;
    color: #0369a1;
}

.lbl-cpo {
    background: #ede9fe;
    color: #6d28d9;
}

/* account indicator */
.acc {
    font-size: 10px;
    font-weight: 600;
    flex-shrink: 0;
    display: flex;
    align-items: flex-start;
    gap: 3px;
    white-space: normal;
    word-break: break-word;
    text-align: right;
}

.acc::before {
    content: '●';
    font-size: 6px;
    line-height: 1.6;
    flex-shrink: 0;
}

.acc-current {
    color: #16a34a;
}

.acc-other {
    color: #94a3b8;
}

/* empty state */
#results .empty {
    padding: 28px 16px;
    text-align: center;
}

.empty-ico {
    font-size: 22px;
    margin-bottom: 6px;
}

.empty-txt {
    font-size: 12.5px;
    color: #94a3b8;
}

.empty-txt strong {
    color: #64748b;
}

/* dropdown footer */
.d-footer {
    border-top: 1px solid #f1f5f9;
    padding: 6px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.f-hints {
    display: flex;
    gap: 10px;
}

.f-hint {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #94a3b8;
}

.f-count {
    font-size: 11px;
    color: #94a3b8;
}

/* overlay (close-on-outside-click) */
.overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100;
}

.overlay.on {
    display: none;
}

.ri-label-blink {
    animation: riLabelBlink 1s infinite;
}

@media (max-width: 640px) {

    .search-header {
        padding: 0 14px;
    }

    #searchblock .dropdown {
        position: fixed;
        top: 36px;
        left: 0;
        right: 0;
        border-radius: 0 0 12px 12px;
        max-height: calc(100dvh - 36px);
    }

    #searchblock .wrapper.focus .dropdown {
        top: 72px;
        max-height: calc(100dvh - 72px);
    }

    #searchblock .dropdown .results {
        max-height: calc(100dvh - 140px) !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    #searchblock .wrapper.focus .dropdown .results {
        max-height: calc(100dvh - 176px) !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .d-footer {
        padding-bottom: env(safe-area-inset-bottom, 8px);
    }

    .d-footer .f-hints {
        display: none;
    }
}

@container (min-width: 760px) {
    .sec-grid {
        grid-template-columns: repeat(2, 1fr);
        column-gap: 1px;
    }
}

@keyframes riLabelBlink {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: .35;
    }
}
