.cabinet-size-selector {
    position: relative;
    width: 100%;
}

.signal-power-config-page .cabinet-size-native-select {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    min-height: 1px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    opacity: 0;
    pointer-events: none;
}

.signal-power-config-page .cabinet-size-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    min-height: 46px;
    padding: 0.65rem 0.85rem;
    border: 1px solid #c7cfda;
    border-radius: 13px;
    background: #ffffff;
    color: #1f2937;
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    box-shadow: none;
    transform: none !important;
}

.signal-power-config-page .cabinet-size-trigger:hover {
    border-color: #93a4bd;
    background: #f8fafc;
    box-shadow: none;
    transform: none !important;
}

.signal-power-config-page .cabinet-size-trigger:focus-visible,
.cabinet-size-option:focus-visible {
    outline: 3px solid rgba(30, 58, 138, 0.22);
    outline-offset: 2px;
}

.cabinet-size-selector.is-open .cabinet-size-trigger {
    border-color: #1e3a8a;
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.cabinet-size-trigger-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cabinet-size-trigger-icon {
    flex: 0 0 auto;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform 0.2s ease;
}

.cabinet-size-selector.is-open .cabinet-size-trigger-icon {
    transform: rotate(225deg) translate(-2px, -2px);
}

.cabinet-size-popup {
    position: fixed;
    z-index: 100000;
    top: 0;
    left: 0;
    width: min(620px, calc(100vw - 32px));
    max-height: min(420px, 52vh);
    overflow: auto;
    padding: 0.6rem;
    border: 1px solid #c7cfda;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.18);
}

.cabinet-size-popup[hidden] {
    display: none;
}

.cabinet-size-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(118px, 1fr));
    gap: 1px;
    overflow: hidden;
    border: 1px solid #cbd5e1;
    border-radius: 7px;
    background: #cbd5e1;
}

.cabinet-size-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    margin: 0;
    padding: 0.55rem 0.65rem;
    border: 0;
    border-radius: 0;
    background: #ffffff;
    color: #334155;
    font: inherit;
    font-size: 0.88rem;
    line-height: 1.25;
    text-align: center;
    cursor: pointer;
    box-shadow: none;
    transform: none !important;
}

.cabinet-size-option:hover {
    background: #eff6ff;
    color: #1e3a8a;
    box-shadow: none;
    transform: none !important;
}

.cabinet-size-option.is-selected {
    background: #1e3a8a;
    color: #ffffff;
    font-weight: 700;
}

.cabinet-size-option-primary,
.cabinet-size-option-description {
    display: block;
    max-width: 100%;
}

.cabinet-size-option-primary {
    font-weight: 600;
}

.cabinet-size-option-description {
    width: 100%;
    margin-top: 0.18rem;
    overflow: hidden;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.2;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cabinet-size-option.is-selected .cabinet-size-option-description {
    color: rgba(255, 255, 255, 0.76);
}

[data-theme="dark"] .signal-power-config-page .cabinet-size-trigger,
[data-theme="dark"] .cabinet-size-option,
[data-theme="dark"] .cabinet-size-popup {
    background: #111827;
    color: #e5e7eb;
    border-color: #475569;
}

[data-theme="dark"] .cabinet-size-grid {
    border-color: #475569;
    background: #475569;
}

[data-theme="dark"] .cabinet-size-option:hover {
    background: #1e293b;
    color: #bfdbfe;
}

[data-theme="dark"] .cabinet-size-option.is-selected {
    background: #2563eb;
    color: #ffffff;
}

[data-theme="dark"] .cabinet-size-option-description {
    color: #94a3b8;
}

[data-theme="dark"] .cabinet-size-option.is-selected .cabinet-size-option-description {
    color: rgba(255, 255, 255, 0.76);
}

@media (max-width: 768px) {
    .cabinet-size-popup {
        width: min(100%, calc(100vw - 24px));
        max-height: 46vh;
        padding: 0.45rem;
    }

    .cabinet-size-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .cabinet-size-option {
        min-height: 46px;
        padding: 0.55rem 0.45rem;
        font-size: 0.84rem;
    }
}
