.microchip-field {
    display: flex;
    align-items: stretch;
    gap: 8px;
}

    .microchip-field .form-control {
        flex: 1;
        min-width: 0;
    }

.microchip-camera {
    display: grid;
    place-items: center;
    flex: 0 0 44px;
    min-height: 44px;
    padding: 0;
    border: 1px solid var(--club-border);
    border-radius: 8px;
    background: var(--club-surface);
    color: var(--club-burgundy);
    font-size: 20px;
    cursor: pointer;
}

    .microchip-camera:hover {
        background: var(--club-cream-dark);
    }

    .microchip-camera:focus-visible,
    .microchip-scanner button:focus-visible {
        outline: 3px solid var(--club-gold);
        outline-offset: 2px;
    }

dialog.microchip-scanner {
    box-sizing: border-box;
    width: min(560px, calc(100vw - 24px));
    max-height: 90vh;
    max-height: 90dvh;
    margin: auto;
    padding: 20px;
    overflow: auto;
    border: 0;
    border-radius: 14px;
    background: var(--club-surface);
    color: var(--club-text);
    box-shadow: 0 20px 70px #0005;
}

.microchip-scanner::backdrop {
    background: rgb(0 0 0 / 65%);
}

.microchip-scanner-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

    .microchip-scanner-header h2 {
        margin: 0;
        font-size: 20px;
    }

.microchip-scanner button {
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--club-border);
    border-radius: 8px;
    background: var(--club-cream);
    color: var(--club-text);
    font: inherit;
    cursor: pointer;
}

.microchip-scanner-header button {
    min-width: 44px;
    padding: 0;
    font-size: 28px;
}

.microchip-scanner video {
    display: block;
    width: 100%;
    max-height: 45vh;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    border-radius: 8px;
    background: #151515;
}

.microchip-scanner [data-status] {
    margin: 14px 0;
    line-height: 1.5;
}

.microchip-scanner [data-number] {
    display: block;
    margin: 12px 0;
    text-align: center;
    font-family: monospace;
    font-size: clamp(20px, 5vw, 28px);
    font-weight: 700;
    color: var(--club-burgundy);
}

.microchip-scanner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

    .microchip-scanner-actions button {
        flex: 1 1 180px;
    }

.microchip-scanner [data-confirm] {
    border-color: var(--club-burgundy);
    background: var(--club-burgundy);
    color: white;
}

.microchip-camera:disabled,
.microchip-scanner button:disabled {
    opacity: .5;
    cursor: default;
}

.microchip-preview {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    max-height: 45vh;
    max-height: 45dvh;
    overflow: hidden;
    border-radius: 10px;
    background: #151515;
}

/* Тези настройки съответстват на изрязването в drawScanArea(). */
.microchip-scanner .microchip-preview video {
    display: block;
    width: 100%;
    height: 100%;
    max-height: none;
    aspect-ratio: auto;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    object-fit: cover;
    object-position: 50% 50%;
}

.microchip-target {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 84%;
    height: 42%;
    box-sizing: border-box;
    transform: translate(-50%, -50%);
    border: 1px solid rgb(255 255 255 / 35%);
    box-shadow: 0 0 0 100vmax rgb(0 0 0 / 48%);
    pointer-events: none;
}

.microchip-corner {
    position: absolute;
    width: 24px;
    height: 24px;
    box-sizing: border-box;
    border: 3px solid var(--club-gold-light);
    filter: drop-shadow(0 0 4px rgb(214 180 100 / 40%));
}

    .microchip-corner.top-left {
        top: -2px;
        left: -2px;
        border-right: 0;
        border-bottom: 0;
        border-top-left-radius: 5px;
    }

    .microchip-corner.top-right {
        top: -2px;
        right: -2px;
        border-left: 0;
        border-bottom: 0;
        border-top-right-radius: 5px;
    }

    .microchip-corner.bottom-left {
        bottom: -2px;
        left: -2px;
        border-right: 0;
        border-top: 0;
        border-bottom-left-radius: 5px;
    }

    .microchip-corner.bottom-right {
        bottom: -2px;
        right: -2px;
        border-left: 0;
        border-top: 0;
        border-bottom-right-radius: 5px;
    }

.microchip-scan-line {
    display: none;
    position: absolute;
    top: 12%;
    left: 8px;
    right: 8px;
    height: 2px;
    background: var(--club-gold-light);
    box-shadow: 0 0 8px rgb(234 217 163 / 80%), 0 0 18px rgb(234 217 163 / 35%);
}

.microchip-preview.is-scanning .microchip-scan-line {
    display: block;
    animation: microchip-sweep 1.8s ease-in-out infinite alternate;
}

@keyframes microchip-sweep {
    from {
        top: 12%;
    }

    to {
        top: 88%;
    }
}

@media (prefers-reduced-motion: reduce) {
    .microchip-preview.is-scanning .microchip-scan-line {
        animation: none;
        top: 50%;
    }
}