:root {
    color-scheme: light;
}

.ap-body-lock {
    overflow: hidden;
}

.ap-modal-root {
    --ap-overlay: rgba(15, 23, 42, 0.45);
    --ap-surface: #ffffff;
    --ap-surface-secondary: #f8f8f8;
    --ap-border: rgba(15, 23, 42, 0.1);
    --ap-border-strong: rgba(15, 23, 42, 0.16);
    --ap-text: #111827;
    --ap-text-soft: #4b5563;
    --ap-muted: #6b7280;
    --ap-primary: #D75E00;
    --ap-primary-strong: #B84F00;
    --ap-success: #0f9d58;
    --ap-warning: #d97706;
    --ap-error: #dc2626;
    --ap-shadow: 0 18px 48px rgba(15, 23, 42, 0.14);
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
}

.ap-modal-root.is-mounted {
    pointer-events: auto;
}

.ap-modal-root.is-open {
    opacity: 1;
}

.ap-overlay {
    position: absolute;
    inset: 0;
    background: var(--ap-overlay);
}

.ap-modal {
    position: relative;
    width: min(960px, 100%);
    max-height: min(88vh, 980px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--ap-border);
    border-radius: 18px;
    background: var(--ap-surface);
    /* box-shadow: var(--ap-shadow); */
    color: var(--ap-text);
    transform: translateY(12px);
    opacity: 0;
    transition: transform 220ms ease, opacity 220ms ease;
}

.ap-modal-root.is-open .ap-modal {
    transform: translateY(0);
    opacity: 1;
}

.ap-secondary-btn,
.ap-ghost-btn,
.ap-primary-btn,
.ap-suggestion {
    border: 0;
    font: inherit;
    cursor: pointer;
    transition: transform 140ms ease, background-color 140ms ease, color 140ms ease, border-color 140ms ease, box-shadow 140ms ease;
}

.ap-modal__content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 22px;
    overflow: hidden;
}

.ap-topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 16px;
    align-items: center;
}

.ap-field {
    display: grid;
    gap: 8px;
}

.ap-field__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--ap-text-soft);
}

.ap-search-input {
    width: 100%;
    height: 54px;
    padding: 0 18px;
    border-radius: 12px;
    border: 1px solid var(--ap-border);
    background: var(--ap-surface);
    color: var(--ap-text);
    font-size: 15px;
    outline: none;
    box-shadow: none;
    transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.ap-search-input:focus {
    border-color: color-mix(in srgb, var(--ap-primary) 45%, var(--ap-border-strong));
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--ap-primary) 12%, transparent);
}

.ap-action-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.ap-visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.ap-secondary-btn,
.ap-ghost-btn,
.ap-primary-btn {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 12px;
    font-weight: 600;
}

.ap-secondary-btn {
    border: 1px solid var(--ap-border);
    background: var(--ap-surface-secondary);
    color: var(--ap-text);
}

.ap-icon-action-btn {
    width: 44px;
    min-width: 44px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    flex: 0 0 44px;
}

.ap-icon-action-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.85;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ap-icon-action-btn.is-loading svg {
    animation: ap-icon-spin 0.9s linear infinite;
}

.ap-secondary-btn:hover,
.ap-ghost-btn:hover {
    background: var(--ap-surface);
    border-color: var(--ap-border-strong);
}

.ap-secondary-btn.is-active {
    border-color: color-mix(in srgb, var(--ap-primary) 35%, var(--ap-border));
    background: color-mix(in srgb, var(--ap-primary) 8%, var(--ap-surface));
    color: var(--ap-primary);
}

@keyframes ap-icon-spin {
    to {
        transform: rotate(360deg);
    }
}

.ap-primary-btn {
    background: var(--ap-primary);
    color: #ffffff;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--ap-primary) 20%, transparent);
}

.ap-primary-btn:hover:not(:disabled) {
    background: var(--ap-primary-strong);
    box-shadow: 0 10px 22px color-mix(in srgb, var(--ap-primary) 24%, transparent);
}

.ap-primary-btn:disabled,
.ap-secondary-btn:disabled,
.ap-ghost-btn:disabled {
    opacity: 0.58;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.ap-ghost-btn {
    border: 1px solid var(--ap-border);
    background: transparent;
    color: var(--ap-text);
}

.ap-results-area {
    display: grid;
    gap: 0;
}

.ap-results-area.is-recent {
    gap: 14px;
    padding: 14px;
    border: 1px solid var(--ap-border);
    border-radius: 14px;
    background: var(--ap-surface-secondary);
}

.ap-recent-panel__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.ap-recent-panel__header strong {
    display: block;
    margin-bottom: 4px;
}

.ap-recent-panel__header p {
    margin: 0;
    font-size: 13px;
    color: var(--ap-text-soft);
}

.ap-back-from-recent-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    align-self: center;
}

.ap-results-area.is-recent .ap-suggestions {
    border: none;
    padding: 0;
    background: transparent;
    box-shadow: none;
}

.ap-suggestions {
    display: grid;
    gap: 6px;
    max-height: min(44vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    border: 1px solid var(--ap-border);
    border-radius: 14px;
    background: var(--ap-surface);
    box-shadow: none;
    scrollbar-gutter: stable;
    position: relative;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 180ms ease, transform 180ms ease, max-height 180ms ease, padding 180ms ease, border-width 180ms ease;
}

.ap-suggestions.is-visible {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.ap-suggestions.is-hiding {
    opacity: 0;
    transform: translateY(-6px);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-width: 0;
    overflow: hidden;
    pointer-events: none;
}

.ap-suggestions.is-visible.is-updating {
    opacity: 0.55;
}

.ap-suggestions.is-updating::before {
    content: "";
    position: sticky;
    top: 0;
    z-index: 1;
    height: 2px;
    margin: -8px -8px 6px;
    border-radius: 14px 14px 0 0;
    background: linear-gradient(90deg, transparent, var(--ap-primary), transparent);
    background-size: 40% 100%;
    background-repeat: no-repeat;
    animation: ap-suggestion-progress 0.9s ease-in-out infinite;
}

@keyframes ap-suggestion-progress {
    0% {
        background-position: -30% 0;
        opacity: 0.35;
    }

    50% {
        opacity: 1;
    }

    100% {
        background-position: 130% 0;
        opacity: 0.35;
    }
}

.ap-suggestion {
    width: 100%;
    display: grid;
    gap: 4px;
    padding: 12px 14px;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: inherit;
}

.ap-suggestion-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 4px;
    align-items: stretch;
}

.ap-suggestion-row .ap-suggestion {
    min-width: 0;
}

.ap-suggestion:hover,
.ap-suggestion.is-active,
.ap-suggestion-row:hover .ap-suggestion,
.ap-suggestion-row:has(.ap-suggestion.is-active) .ap-suggestion {
    background: color-mix(in srgb, var(--ap-primary) 6%, var(--ap-surface-secondary));
    border-color: color-mix(in srgb, var(--ap-primary) 18%, var(--ap-border));
}

.ap-suggestion-clear {
    width: 40px;
    min-width: 40px;
    border: 1px solid transparent;
    border-radius: 10px;
    background: transparent;
    color: var(--ap-muted);
    cursor: pointer;
    display: inline-grid;
    place-items: center;
    transition: background-color 140ms ease, color 140ms ease, border-color 140ms ease;
}

.ap-suggestion-clear svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

.ap-suggestion-clear:hover {
    background: color-mix(in srgb, var(--ap-error) 10%, var(--ap-surface));
    border-color: color-mix(in srgb, var(--ap-error) 22%, var(--ap-border));
    color: var(--ap-error);
}

.ap-suggestion__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.ap-suggestion__title {
    font-size: 14px;
    line-height: 1.35;
    color: var(--ap-text);
    word-break: break-word;
}

.ap-suggestion__badge {
    flex: 0 0 auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--ap-primary) 12%, var(--ap-surface));
    color: var(--ap-primary);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.ap-suggestion__meta {
    font-size: 12px;
    color: var(--ap-muted);
}

.ap-suggestions-state {
    padding: 14px;
    border-radius: 10px;
    text-align: center;
    color: var(--ap-text-soft);
    background: var(--ap-surface-secondary);
}

.ap-status {
    font-size: 13px;
    color: var(--ap-muted);
}

.ap-status[data-variant="success"] {
    color: var(--ap-success);
}

.ap-status[data-variant="warning"] {
    color: var(--ap-warning);
}

.ap-status[data-variant="error"] {
    color: var(--ap-error);
}

.ap-map-panel {
    display: grid;
    gap: 14px;
    max-height: min(56vh, 520px);
    overflow: auto;
    padding: 14px;
    border: 1px solid var(--ap-border);
    border-radius: 14px;
    background: var(--ap-surface-secondary);
}

.ap-map-panel__header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
}

.ap-map-panel__header strong {
    display: block;
    margin-bottom: 4px;
}

.ap-map-panel__header p {
    margin: 0;
    font-size: 13px;
    color: var(--ap-text-soft);
}

.ap-back-to-list-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    align-self: center;
}

.ap-map {
    width: 100%;
    height: min(42vh, 380px);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--ap-border);
}

.ap-map .gm-style iframe + div {
    border: none !important;
}

.ap-selection-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    align-items: center;
}

.ap-selection-card {
    display: grid;
    gap: 8px;
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--ap-border);
    border-radius: 14px;
    background: var(--ap-surface-secondary);
}

.ap-suggestions[hidden],
.ap-recent-panel__header[hidden],
.ap-map-panel[hidden],
.ap-selection-row[hidden],
.ap-status[hidden] {
    display: none !important;
}

.ap-selection-card__label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--ap-primary);
}

.ap-selection-action {
    width: 44px;
    height: 44px;
    min-width: 44px;
    padding: 0;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 12px;
    background: var(--ap-primary);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 8px 18px color-mix(in srgb, var(--ap-primary) 18%, transparent);
    transition: transform 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

.ap-selection-action svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ap-selection-action:hover:not(:disabled) {
    background: var(--ap-primary-strong);
    box-shadow: 0 10px 22px color-mix(in srgb, var(--ap-primary) 22%, transparent);
}

.ap-selection-action:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.ap-selection-card__value {
    font-size: 15px;
    line-height: 1.45;
}

.ap-selection-card__meta {
    font-size: 13px;
    color: var(--ap-text-soft);
}

@media (max-width: 820px) {
    .ap-modal-root {
        padding: 14px;
    }

    .ap-modal {
        width: 100%;
        max-height: 92vh;
        border-radius: 16px;
    }

    .ap-modal__content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .ap-topbar {
        grid-template-columns: 1fr;
    }

    .ap-action-group {
        justify-content: stretch;
    }

    .ap-action-group > * {
        flex: 1 1 180px;
    }

    .ap-action-group > .ap-icon-action-btn {
        flex: 0 0 44px;
    }
}

@media (max-width: 560px) {
    .ap-map-panel {
        max-height: min(52vh, 420px);
    }

    .ap-selection-row {
        grid-template-columns: 1fr auto;
        align-items: center;
    }

    .ap-map {
        height: 300px;
    }

    .ap-suggestions {
        max-height: min(38vh, 320px);
    }
}
