.selector-page {
    min-height: 100vh;
    padding: clamp(1rem, 4vw, 3rem) clamp(1rem, 4vw, 3rem) max(clamp(1rem, 4vw, 3rem), env(safe-area-inset-bottom));
    color: var(--acme-color-text-default);
    background: var(--body-background-color);
}

.selector-panel {
    width: min(100%, 70rem);
    margin-inline: auto;
    overflow: hidden;
    border: 1px solid var(--acme-color-border-light);
    border-radius: var(--acme-radius-lg);
    background: var(--acme-color-surface);
    box-shadow: var(--acme-shadow-sm);
}

.selector-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--acme-color-border-light);
    background: var(--acme-color-surface-muted);
}

.selector-header > h1 {
    margin: 0;
    font-size: clamp(1.2rem, 3vw, 1.55rem);
    font-weight: 700;
    line-height: 1.25;
}

.selector-search {
    flex: 0 1 20rem;
    width: 100%;
    color: var(--acme-color-text-muted);
    font-size: 0.8rem;
    font-weight: 600;
}

.selector-search__field {
    position: relative;
    display: block;
    margin-top: 0.35rem;
}

.selector-search__field > i {
    position: absolute;
    top: 50%;
    left: 0.85rem;
    z-index: 1;
    color: var(--acme-color-text-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.selector-search .form-control {
    min-height: 2.75rem;
    color: var(--acme-color-text-default);
    border-color: var(--acme-color-border-light);
    border-radius: var(--acme-radius-md);
    background: var(--acme-color-surface);
    font-size: 1rem;
}

.selector-search .search-container {
    width: 100%;
    min-height: 1.5rem;
    margin-top: 0.35rem;
    border-color: var(--acme-color-border-light) !important;
    border-radius: var(--acme-radius-md) !important;
    background: var(--acme-color-surface);
    transition: border-color var(--acme-transition-fast), box-shadow var(--acme-transition-fast);
}

.selector-search .search-container:focus-within {
    width: 100%;
    border-color: var(--acme-color-primary-action) !important;
    box-shadow: var(--acme-focus-ring);
}

.selector-search .search-input {
    height: 2.625rem !important;
    margin-right: 0 !important;
    padding: 0.5rem 0.75rem;
    color: var(--acme-color-text-default);
    background: transparent;
}

.selector-search .form-control:focus {
    border-color: var(--acme-color-primary-action);
    box-shadow: none;
}

.selector-content {
    min-height: 12rem;
    padding: 0.25rem;
}

.selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr));
    gap: 0.75rem;
}

.selector-card {
    display: flex;
    min-width: 0;
    min-height: 5rem;
    align-items: center;
    gap: 0.8rem;
    padding: 0.85rem 1rem;
    color: var(--acme-color-text-default);
    border: 1px solid var(--acme-color-border-light);
    border-radius: var(--acme-radius-md);
    background: var(--acme-color-surface);
    box-shadow: 0 1px 3px var(--acme-overlay-10);
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    transition: border-color var(--acme-transition-fast), background-color var(--acme-transition-fast), box-shadow var(--acme-transition-fast);
}

@media (hover: hover) and (pointer: fine) {
    .selector-card:hover:not(:disabled) {
        border-color: color-mix(in srgb, var(--acme-color-primary-action) 45%, var(--acme-color-border-light));
        background: var(--acme-color-surface-hover);
        box-shadow: var(--acme-shadow-sm);
    }
}

.selector-card:active:not(:disabled) {
    background: color-mix(in srgb, var(--acme-color-primary-action) 12%, var(--acme-color-surface));
}

.selector-card:focus-visible,
.selector-card.is-focused {
    outline: 2px solid var(--acme-color-primary-action);
    outline-offset: 2px;
}

.selector-card.is-selected {
    border-color: var(--acme-color-primary-action);
    background: color-mix(in srgb, var(--acme-color-primary-action) 8%, var(--acme-color-surface));
    box-shadow: inset 3px 0 0 var(--acme-color-primary-action), 0 1px 3px var(--acme-overlay-10);
}

.selector-card:disabled {
    cursor: wait;
    opacity: 0.6;
}

.selector-card__icon {
    display: inline-grid;
    flex: 0 0 2.75rem;
    width: 2.75rem;
    min-height: 2.75rem;
    place-items: center;
    color: var(--acme-color-primary-action);
    border-radius: var(--acme-radius-md);
    background: color-mix(in srgb, var(--acme-color-primary-action) 10%, var(--acme-color-surface));
    font-size: 1.15rem;
}

.selector-card__content {
    display: flex;
    min-width: 0;
    flex: 1;
    flex-direction: column;
    gap: 0.2rem;
}

.selector-card__content strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selector-card__content small,
.selector-card__chevron {
    color: var(--acme-color-text-muted);
}

.selector-card__chevron {
    flex: 0 0 auto;
}

.selector-state {
    display: flex;
    min-height: 9rem;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 1rem;
    color: var(--acme-color-text-muted);
    flex-direction: column;
    text-align: center;
}

.selector-state > i {
    margin-bottom: 0.35rem;
    color: var(--acme-color-primary-action);
    font-size: 1.5rem;
}

.selector-state strong {
    color: var(--acme-color-text-default);
}

.selector-table-shell {
    width: 100%;
    max-height: min(70vh, 42rem);
    overflow: auto;
    border: 1px solid var(--acme-color-border-light);
    border-radius: var(--acme-radius-md);
    scrollbar-width: thin;
}

.selector-table {
    width: 100%;
    margin: 0;
    color: var(--acme-color-text-default);
    table-layout: fixed;
}

.selector-table--company {
    min-width: 52rem;
}

.selector-table--compact {
    min-width: 22rem;
}

.selector-table__number-column {
    width: 4rem;
}

.selector-table__short-name-column {
    width: 9rem;
}

.company-table__initial-column {
    width: 5.5rem;
}

.company-table__name-column {
    width: 18rem;
}

.company-table__fiscal-column {
    width: 6.5rem;
}

.company-table__date-column {
    width: 8rem;
}

.selector-table th,
.selector-table td {
    height: 2.5rem;
    padding: 0.45rem 0.65rem;
    overflow: hidden;
    color: var(--acme-color-text-default);
    border-color: var(--acme-color-border-light);
    vertical-align: middle;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.selector-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    color: var(--acme-color-surface);
    background: var(--table-header-bg);
    font-size: 0.825rem;
    font-weight: 700;
}

.selector-table tbody tr {
    cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
    .selector-table tbody tr:hover td {
        background: var(--acme-color-surface-hover);
    }
}

.selector-table tbody tr:focus-visible {
    outline: 2px solid var(--acme-color-primary-action);
    outline-offset: -2px;
}

.selector-table tbody tr.is-selected td {
    background: color-mix(in srgb, var(--acme-color-primary-action) 10%, var(--acme-color-surface));
}

.company-table__center,
.selector-table__center {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.selector-table__sticky {
    position: sticky;
    left: 0;
    z-index: 1;
    overflow: visible !important;
    background: var(--table-header-bg);
    box-shadow: 1px 0 0 var(--acme-color-border-light);
    font-weight: 700;
    text-align: center;
    text-overflow: clip !important;
}

.selector-table th.selector-table__sticky {
    z-index: 3;
}

.selector-table tbody tr.is-selected .selector-table__sticky {
    background: color-mix(in srgb, var(--acme-color-primary-action) 10%, var(--acme-color-surface));
}

.selector-table__state {
    height: 9rem !important;
    text-align: center;
}

@media (max-width: 576px) {
    .selector-page {
        padding: 0 0 env(safe-area-inset-bottom);
    }

    .selector-panel {
        min-height: 100vh;
        min-height: 100dvh;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .selector-header {
        align-items: stretch;
        gap: 1rem;
        padding: max(1rem, env(safe-area-inset-top)) 1rem 1rem;
        flex-direction: column;
    }

    .selector-search {
        flex-basis: auto;
    }

    .selector-content {
        padding: 1rem;
    }

    .selector-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .selector-card {
        min-height: 5.5rem;
        padding: 0.75rem;
    }

    .selector-card__content strong {
        white-space: normal;
    }

    .selector-content--table {
        padding: 0.75rem;
    }

    .selector-table-shell {
        max-height: calc(100dvh - 9.5rem);
    }

    .selector-table th,
    .selector-table td {
        height: 2.75rem;
    }
}

@media (max-width: 360px) {
    .selector-header {
        padding-inline: 0.75rem;
    }
}

@media (prefers-reduced-motion: reduce) {
    .selector-card {
        transition: none;
    }
}
