.selector-body {
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e, #1e3a8a);
    background-size: 400% 400%;
    animation: selectorGradient 18s ease infinite;
}

@keyframes selectorGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.selector-blob {
    position: fixed;
    border-radius: 50%;
    filter: blur(70px);
    opacity: 0.35;
    pointer-events: none;
    z-index: 0;
}

.selector-blob-1 {
    width: 420px;
    height: 420px;
    top: -120px;
    left: -100px;
    background: #7c3aed;
    animation: selectorFloat1 14s ease-in-out infinite;
}

.selector-blob-2 {
    width: 380px;
    height: 380px;
    bottom: -140px;
    right: -100px;
    background: #0ea5e9;
    animation: selectorFloat2 16s ease-in-out infinite;
}

.selector-blob-3 {
    width: 300px;
    height: 300px;
    bottom: 10%;
    left: 8%;
    background: #f97316;
    animation: selectorFloat1 20s ease-in-out infinite reverse;
}

@keyframes selectorFloat1 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(40px, 30px) scale(1.1); }
}

@keyframes selectorFloat2 {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-30px, -40px) scale(1.08); }
}

.selector-panel {
    position: relative;
    z-index: 1;
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 24px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
    padding: 2rem;
    color: #fff;
    animation: selectorPanelIn 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes selectorPanelIn {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.selector-icon-badge {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 8px 20px rgba(99, 102, 241, 0.5);
    animation: selectorIconPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both;
}

@keyframes selectorIconPop {
    from { opacity: 0; transform: scale(0.5) rotate(-15deg); }
    to { opacity: 1; transform: scale(1) rotate(0); }
}

.selector-subtitle {
    color: rgba(255, 255, 255, 0.65);
    font-size: 0.9rem;
}

.selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 14px;
}

/* Pantalla de empresas: todos los cuadros de la misma altura (el de nombre largo no descuadra la fila). */
.selector-grid-igual {
    grid-auto-rows: 1fr;
}

.selector-grid-igual > div,
.selector-grid-igual > div > form {
    height: 100%;
}

.selector-grid-igual .selector-tile {
    height: 100%;
}

/* El contenido del cuadro va pegado arriba (un <button> lo centra solo): icono, numero y papelera siempre en la misma fila. */
.selector-grid-igual .selector-tile:not(.selector-tile-add) {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
}

/* Icono y numero en la misma linea, y el nombre debajo (ahorra una linea por cuadro). */
.selector-grid-igual .selector-tile-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 26px;   /* la altura de la papelera, para que todos los cuadros arranquen igual */
    margin-bottom: 0.45rem;
}

.selector-grid-igual .selector-tile-icon {
    margin-bottom: 0;
    font-size: 1.2rem;
}

.selector-grid-igual .selector-tile-code {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    opacity: 0.95;
}

/* Papelera: en la fila de arriba, a la derecha del icono y el numero (solo la ve quien puede eliminar). */
.selector-btn-eliminar {
    position: absolute;
    top: 1.25rem;
    right: 1rem;
    z-index: 2;
    width: 26px;
    height: 26px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.85);
}

/* El nombre ocupa como maximo 2 lineas; si es mas largo se corta con "…" (el nombre completo sale al pasar el mouse). */
.selector-grid-igual .selector-tile-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.selector-grid-igual .selector-nombre-largo {
    font-size: 0.9rem;
}

.selector-grid-igual .selector-nombre-muy-largo {
    font-size: 0.8rem;
}

.selector-grid-igual .selector-sin-resultados {
    grid-column: 1 / -1;
    text-align: center;
    padding: 1.75rem 0.5rem;
    color: rgba(255, 255, 255, 0.75);
}

/* Buscador de empresas (aparece desde 9 empresas). */
.selector-buscar {
    position: relative;
    margin-bottom: 0.4rem;
}

.selector-buscar-campo {
    width: 100%;
    padding: 0.55rem 2.25rem 0.55rem 2.35rem;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    outline: none;
}

.selector-buscar-campo::placeholder {
    color: rgba(255, 255, 255, 0.55);
}

.selector-buscar-campo:focus {
    border-color: #8ab4ff;
    box-shadow: 0 0 0 3px rgba(138, 180, 255, 0.25);
}

.selector-buscar-lupa {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.6);
    pointer-events: none;
}

.selector-buscar-limpiar {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.75);
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

.selector-buscar-limpiar:hover {
    color: #fff;
}

.selector-buscar-cuenta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.65);
    margin-bottom: 0.75rem;
}

.selector-buscar mark {
    background: rgba(255, 255, 255, 0.4);
    color: inherit;
}

.selector-tile mark {
    background: rgba(255, 255, 255, 0.4);
    color: inherit;
    border-radius: 3px;
    padding: 0 1px;
}

.selector-tile {
    position: relative;
    border: none;
    border-radius: 16px;
    padding: 1.25rem 1rem;
    text-align: left;
    color: #fff;
    cursor: pointer;
    opacity: 0;
    transform: translateY(14px);
    animation: selectorTileIn 0.45s ease forwards;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.selector-tile:hover {
    transform: translateY(-6px) scale(1.02);
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.35);
    filter: brightness(1.08);
}

.selector-tile:active {
    transform: translateY(-2px) scale(0.99);
}

@keyframes selectorTileIn {
    to { opacity: 1; transform: translateY(0); }
}

.selector-tile-icon {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    opacity: 0.9;
}

.selector-tile-code {
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    opacity: 0.85;
    text-transform: uppercase;
}

.selector-tile-name {
    font-weight: 600;
    font-size: 1rem;
    line-height: 1.25;
    margin-top: 2px;
    word-break: break-word;
}

.selector-tile-add {
    background: transparent;
    border: 2px dashed rgba(255, 255, 255, 0.35);
    color: rgba(255, 255, 255, 0.85);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 6px;
    box-shadow: none;
}

.selector-tile-add:hover {
    border-color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.06);
    box-shadow: none;
    filter: none;
}

.selector-tile-add i {
    font-size: 1.5rem;
}

.selector-badge-actual {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    background: rgba(255, 255, 255, 0.25);
    padding: 2px 7px;
    border-radius: 20px;
    animation: selectorPulse 1.8s ease-in-out infinite;
}

@keyframes selectorPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.5); }
    50% { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0); }
}

.selector-badge-cerrado {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.6rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.35);
    padding: 2px 7px;
    border-radius: 20px;
}

.selector-topbar {
    position: relative;
    z-index: 1;
}

.selector-link-muted {
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: 0.85rem;
}

.selector-link-muted:hover {
    color: #fff;
}

/* Modales de "Nueva empresa" / "Nuevo periodo" */
.selector-modal .modal-dialog {
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
    transform: scale(0.85) translateY(20px);
}

.selector-modal.show .modal-dialog {
    transform: scale(1) translateY(0);
}

.selector-modal .modal-content {
    border: none;
    border-radius: 22px;
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.4);
}

.selector-modal .modal-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    padding: 1.5rem 1.5rem 1.25rem;
    position: relative;
    overflow: hidden;
}

.selector-modal .modal-header::after {
    content: "";
    position: absolute;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    top: -80px;
    right: -40px;
}

.selector-modal .modal-header-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
    margin-bottom: 0.6rem;
    position: relative;
    z-index: 1;
}

.selector-modal .modal-title {
    color: #fff;
    font-weight: 700;
    position: relative;
    z-index: 1;
}

.selector-modal .btn-close {
    position: relative;
    z-index: 1;
    filter: invert(1) brightness(2);
    opacity: 0.85;
}

.selector-modal .modal-body {
    padding: 1.5rem;
}

.selector-modal .form-label {
    font-weight: 600;
    font-size: 0.85rem;
}

.selector-suggest-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: #7c3aed;
    background: #f1eefe;
    padding: 2px 8px;
    border-radius: 20px;
    margin-top: 6px;
}

.selector-choice-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.selector-choice {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    border: 2px solid #e5e3f5;
    border-radius: 14px;
    padding: 12px 14px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease, transform 0.15s ease;
}

.selector-choice:hover {
    border-color: #b7aef0;
    transform: translateY(-1px);
}

.selector-choice.selected {
    border-color: #7c3aed;
    background: #f6f4ff;
}

.selector-choice input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.selector-choice-icon {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1eefe;
    color: #7c3aed;
    font-size: 1.05rem;
    flex-shrink: 0;
    transition: background 0.2s ease, color 0.2s ease;
}

.selector-choice.selected .selector-choice-icon {
    background: #7c3aed;
    color: #fff;
}

.selector-choice-text {
    flex: 1;
}

.selector-choice-text strong {
    display: block;
    font-size: 0.9rem;
    color: #2b2b3d;
}

.selector-choice-text small {
    color: #8a8a99;
    font-size: 0.76rem;
}

.selector-choice-check {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #d6d3ea;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 0.65rem;
    transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.selector-choice.selected .selector-choice-check {
    border-color: #7c3aed;
    background: #7c3aed;
    color: #fff;
}

.selector-modal .modal-footer {
    border: none;
    padding: 0.5rem 1.5rem 1.5rem;
}

.btn-selector-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border: none;
    color: #fff;
    font-weight: 600;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.btn-selector-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(124, 58, 237, 0.4);
    color: #fff;
}

/* Pantalla de login */
.login-logo {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    box-shadow: 0 10px 28px rgba(99, 102, 241, 0.45);
    animation:
        selectorIconPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.1s both,
        selectorIconFloat 3.2s ease-in-out 0.7s infinite;
}
@keyframes selectorIconFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50%      { transform: translateY(-7px) rotate(-3deg); }
}

.login-title {
    font-weight: 700;
    margin-top: 0.9rem;
}

.login-subtitle {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.88rem;
}

.selector-field {
    position: relative;
}

.selector-field .selector-field-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.9rem;
    pointer-events: none;
    transition: color 0.2s ease;
}

.selector-field input {
    background: rgba(255, 255, 255, 0.08);
    border: 1.5px solid rgba(255, 255, 255, 0.15);
    color: #fff;
    border-radius: 12px;
    padding: 0.65rem 0.9rem 0.65rem 2.4rem;
    width: 100%;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.selector-field input::placeholder {
    color: rgba(255, 255, 255, 0.35);
}

.selector-field input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.13);
    border-color: #8b5cf6;
    box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.2);
}

.selector-field input:focus ~ .selector-field-icon {
    color: #c4b5fd;
}

.selector-field-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 4px;
}

.selector-field-toggle:hover {
    color: #fff;
}
