.shared-select {
    position: relative;
    width: 100%;
    min-width: 0;
}

.shared-select-native {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    opacity: 0 !important;
    pointer-events: none !important;
    clip-path: inset(50%);
}

.shared-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    min-width: 0;
    min-height: 44px;
    padding: 10px 14px;
    background: var(--surface);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font: inherit;
    text-align: start;
    cursor: pointer;
    transition: border-color var(--transition-fast), background var(--transition-fast);
}

.shared-select-value {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.input-with-icon .shared-select-trigger {
    padding-inline-start: 40px;
}

.shared-select-trigger > svg {
    flex-shrink: 0;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.shared-select-trigger[aria-expanded="true"] > svg {
    transform: rotate(180deg);
}

.shared-select-trigger:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--surface-elevated);
}

.shared-select-trigger:focus-visible,
.shared-option:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.shared-select-trigger[aria-expanded="true"] {
    border-color: var(--primary);
}

.shared-select-trigger[aria-invalid="true"] {
    border-color: var(--danger);
}

.shared-select-trigger:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.shared-select-error {
    margin: 6px 0 0;
    color: var(--danger);
    font-size: 0.8125rem;
}

.shared-popup {
    position: fixed;
    z-index: 11020;
    box-sizing: border-box;
    min-width: 0;
    padding: 6px;
    margin: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--text-muted) transparent;
}

/* Override the calendar's former dropdown placement and entrance styles. */
.shared-popup.shared-menu,
.shared-popup.shared-popover {
    right: auto;
    bottom: auto;
    opacity: 1;
    visibility: visible;
    transform: none;
    transition: none;
}

.shared-option {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 40px;
    padding: 10px 12px;
    border: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-primary);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.35;
    text-align: start;
    overflow-wrap: anywhere;
    cursor: pointer;
}

.shared-option[aria-selected="true"],
.shared-option[aria-checked="true"] {
    background: var(--surface-elevated);
    font-weight: 600;
}

.shared-option[aria-selected="true"]::after,
.shared-option[aria-checked="true"]::after {
    content: '';
    flex-shrink: 0;
    width: 8px;
    height: 4px;
    margin-inline-start: auto;
    border-left: 2px solid var(--primary);
    border-bottom: 2px solid var(--primary);
    transform: rotate(-45deg);
}

.shared-option.is-highlighted,
.shared-option:hover:not(:disabled),
.shared-option:focus-visible {
    background: var(--surface-elevated);
}

.shared-option:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.shared-option-group {
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    font-weight: 600;
}

.shared-search-header {
    position: sticky;
    top: -6px;
    z-index: 1;
    padding: 4px 0 8px;
    background: var(--surface);
}

.shared-dropdown-search {
    width: 100%;
    box-sizing: border-box;
    min-height: 36px;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-elevated);
    color: var(--text-primary);
    font: inherit;
    font-size: 0.875rem;
    line-height: 1.4;
    caret-color: var(--primary);
}

.shared-dropdown-search::placeholder {
    color: var(--text-secondary);
}

.shared-dropdown-search:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.shared-search-empty {
    padding: 16px 12px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.shared-popup [hidden] {
    display: none !important;
}

.shared-tooltip {
    position: fixed;
    z-index: 11030;
    max-width: min(280px, calc(100vw - 16px));
    padding: 8px 12px;
    background: var(--text-primary);
    color: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-md);
    font-size: 0.8125rem;
    line-height: 1.4;
    overflow-wrap: anywhere;
    pointer-events: none;
}

/* All old CSS-only calendar tooltips now use the shared floating tooltip. */
html body [data-tooltip]::before,
html body [data-tooltip]::after {
    content: none !important;
    display: none !important;
}

.shared-popup[hidden],
.shared-tooltip[hidden],
.shared-select[hidden],
.shared-select-error[hidden] {
    display: none !important;
}

.year-selector .shared-select {
    width: auto;
    min-width: 100px;
}

.shared-popover .mini-cal-day {
    border: 0;
    font-family: inherit;
}

.shared-popover .mini-cal-day:not(.today):not(.selected):not(:hover) {
    background: transparent;
}

.shared-popover .mini-cal-day:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

@media (pointer: coarse) {
    .shared-option {
        min-height: 44px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .shared-select-trigger,
    .shared-select-trigger > svg {
        transition: none;
    }
}

@media print {
    .shared-popup,
    .shared-tooltip {
        display: none !important;
    }
}
