.lookup {
    width: 100%;
    max-width: 640px;
    container-type: inline-size;
    text-align: left;
    font-family: inherit;
    color: inherit;
}

.lookup *,
.lookup *::before,
.lookup *::after {
    box-sizing: border-box;
}

.main-section .right .lookup,
.main-section .right .lookup *,
.main-section .right .lookup *::before,
.main-section .right .lookup *::after {
    border-radius: 0 !important;
}

.lookup [hidden] {
    display: none !important;
}

.lookup-errors {
    margin: 0 0 16px;
    padding: 12px 16px;
    border-left: 4px solid #8a1c14;
    background: #fdecea;
    color: #8a1c14;
}

.lookup-errors p {
    margin: 0;
}

.lookup-errors p + p {
    margin-top: 4px;
}

.lookup-form {
    display: grid;
    gap: 16px;
    margin-bottom: 28px;
}

.lookup-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

.lookup-field input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #c9ccd1;
    -webkit-appearance: none;
    appearance: none;
    background: #fff;
    color: inherit;
    font: inherit;
    font-size: 16px;
}

.lookup-field input:focus {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}

.lookup-hint {
    margin: 0;
    font-size: 0.875rem;
    opacity: 0.7;
}

.lookup-submit {
    justify-self: start;
}

@container (min-width: 520px) {
    .lookup-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .lookup-hint,
    .lookup-submit {
        grid-column: 1 / -1;
    }
}

.lookup-submit,
.lookup-btn {
    padding: 12px 28px;
    border: 1px solid #111;
    -webkit-appearance: none;
    appearance: none;
    background: #111;
    color: #fff;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
}

.lookup-submit:hover {
    opacity: 0.88;
}

.lookup-btn {
    min-width: 120px;
    padding: 12px 20px;
    background: #fff;
    color: #111;
}

.lookup-btn-primary {
    background: #111;
    color: #fff;
}

.lookup-btn:hover:not(:disabled) {
    background: #111;
    color: #fff;
}

.lookup-btn-primary:hover:not(:disabled) {
    background: #333;
}

.lookup-btn:focus-visible,
.lookup-submit:focus-visible {
    outline: 2px solid #111;
    outline-offset: 2px;
}

.lookup-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.lookup-results {
    margin-bottom: 24px;
    scroll-margin-top: 16px;
}

.lookup-count {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 4px 12px;
    margin: 0 0 10px;
    font-weight: 600;
}

.lookup-count span {
    font-size: 0.875rem;
    font-weight: 400;
    opacity: 0.65;
}

.lookup-empty {
    margin: 0;
    padding: 16px;
    border: 1px solid #dfe3ea;
    border-left: 4px solid #111;
    background: #fff;
}

.lookup-pager {
    border: 1px solid #dfe3ea;
    background: #fff;
}

.lookup-progress {
    padding: 16px 20px;
    border-bottom: 1px solid #e8ebf0;
}

.lookup-step {
    margin: 0 0 8px;
    font-size: 0.875rem;
    font-weight: 600;
}

.lookup-bar {
    height: 6px;
    background: #e2e4e8;
}

.lookup-bar span {
    display: block;
    width: 0;
    height: 100%;
    background: #111;
    transition: width 0.25s ease;
}

.lookup-list {
    margin: 0;
    padding: 0;
}

.lookup-pager.is-stepper .lookup-list {
    display: grid;
}

.lookup-item {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 20px;
}

.lookup-item + .lookup-item {
    border-top: 1px solid #e8ebf0;
}

.lookup-pager.is-stepper .lookup-item {
    grid-area: 1 / 1;
    border-top: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0s linear 0.2s;
}

.lookup-pager.is-stepper .lookup-item.is-current {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

.lookup-item-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px 12px;
}

.lookup-item-head > div {
    flex: 1 1 160px;
    min-width: 0;
}

.lookup-kind {
    margin: 0 0 2px;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.65;
}

.lookup-item-head h3 {
    margin: 0;
    font-size: 1.2rem;
    line-height: 1.25;
    overflow-wrap: anywhere;
}

.lookup-text {
    max-height: calc(1.5em * 6 + 28px);
    margin: 0;
    padding: 14px 16px;
    overflow-y: auto;
    border-left: 4px solid #111;
    background:
        linear-gradient(#f4f6fa 30%, rgba(244, 246, 250, 0)) 0 0 / 100% 28px no-repeat local,
        linear-gradient(rgba(244, 246, 250, 0), #f4f6fa 70%) 0 100% / 100% 28px no-repeat local,
        linear-gradient(rgba(11, 19, 48, 0.18), rgba(11, 19, 48, 0)) 0 0 / 100% 10px no-repeat scroll,
        linear-gradient(rgba(11, 19, 48, 0), rgba(11, 19, 48, 0.18)) 0 100% / 100% 10px no-repeat scroll,
        #f4f6fa;
    line-height: 1.5;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.lookup-meta {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 16px;
    margin: 0;
    padding-top: 16px;
    border-top: 1px solid #e8ebf0;
}

.lookup-meta div {
    min-width: 0;
}

.lookup-meta dt {
    font-size: 0.75rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.65;
}

.lookup-meta dd {
    margin: 3px 0 0;
    font-weight: 500;
    overflow-wrap: anywhere;
}

.lookup-meter {
    display: block;
    height: 4px;
    margin-top: 8px;
    background: #e2e4e8;
}

.lookup-meter span {
    display: block;
    height: 100%;
    background: #111;
}

.lookup-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-top: 1px solid #e8ebf0;
    background: #fafbfd;
}

.badge {
    display: inline-block;
    flex-shrink: 0;
    padding: 4px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-unread,
.badge-pay-pending {
    background: #fff4d6;
    color: #7a5200;
}

.badge-partial {
    background: #e3f0ff;
    color: #0b4a8f;
}

.badge-done,
.badge-pay-paid {
    background: #e1f5e6;
    color: #14602b;
}

.badge-archived {
    background: #ececec;
    color: #444;
}

.badge-pay-cancelled {
    background: #fdecea;
    color: #8a1c14;
}

.lookup-back {
    display: inline-block;
    color: inherit;
    font-weight: 600;
}

@container (max-width: 380px) {
    .lookup-item {
        padding: 16px 14px;
    }

    .lookup-progress {
        padding: 14px;
    }

    .lookup-nav {
        padding: 12px 14px;
    }

    .lookup-btn {
        flex: 1 1 0;
        min-width: 0;
        padding: 12px 8px;
    }

    .lookup-text {
        padding: 12px;
    }
}

@container (max-width: 300px) {
    .lookup-meta {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: reduce) {
    .lookup-bar span,
    .lookup-pager.is-stepper .lookup-item {
        transition: none;
    }
}