@media screen and (min-width: 769px) {
    .container {
        width: 100%;
        margin-left: 0 !important;
    }
    .header-text { margin-left: 0; }
}

@media screen and (max-width: 768px) {
    .container {
        width: 100% !important;
        margin-left: 0 !important;
        padding: 10px;
    }
    .header-text { margin-left: 0 !important; }
    .main-logo { width: 60px; height: 60px; }
    .floating-rubro-list { 
        width: min(280px, 90vw) !important;
        left: 10px !important;
    }
    .budget-table { 
        font-size: 0.75em; /* Mantenemos el tamaño de fuente para legibilidad */
        table-layout: fixed; /* Forzamos un layout fijo para controlar los anchos de columna */
        width: 100%; /* Ocupa el 100% del ancho de su contenedor (el área de scroll) */
        min-width: 620px; /* Aumentado ligeramente para dar estabilidad al ancho total */
    }

    /* 1. Número de ítem (Pos): El más fino */
    .budget-table th:nth-child(1),
    .budget-table td:nth-child(1) {
        width: 30px;
        min-width: 30px;
        padding: 4px 0 !important;
        text-align: center;
        color: #94a3b8;
        font-size: 0.7rem;
    }

    /* 2. Nombre del Rubro: El que ocupa mayor porcentaje */
    .budget-table th:nth-child(2),
    .budget-table td:nth-child(2) {
        width: 220px; 
        min-width: 220px;
        white-space: normal;
        word-break: break-word;
        font-weight: 600;
    }

    /* 3. Unidad: Fina (Siguiendo tu nueva instrucción de orden) */
    .budget-table th:nth-child(3),
    .budget-table td:nth-child(3) {
        width: 35px; 
        min-width: 35px;
        font-size: 0.7rem;
        text-align: center;
        padding: 4px 0px !important;
        overflow: hidden;
    }

    /* 4. Cantidad (Input): Mediana, más ancha que unidades */
    .budget-table th:nth-child(4),
    .budget-table td:nth-child(4) {
        width: 85px;
        min-width: 85px;
        padding: 4px 2px !important;
    }

    /* 5. Precio Unitario: No tan grande */
    .budget-table th:nth-child(5),
    .budget-table td:nth-child(5) {
        width: 95px;
        min-width: 95px;
    }

    /* 6. Parcial (Subtotal): Un poco grande pero < Rubro */
    .budget-table th:nth-child(6),
    .budget-table td:nth-child(6) {
        width: 110px;
        min-width: 110px;
        font-weight: 700;
    }

    /* 7. Acciones: Lo justo */
    .budget-table th:nth-child(7),
    .budget-table td:nth-child(7) {
        width: 45px;
        min-width: 45px;
        text-align: right;
    }

    /* Compactamos los controles de cantidad para móvil */
    .budget-qty-cell .quantity-control-modern {
        min-width: unset; /* Eliminamos la restricción de min-width de escritorio */
        width: 100%; /* Ocupa todo el ancho de la celda */
        flex-wrap: nowrap; /* Forzamos que se mantengan en una sola línea */
        gap: 2px; /* Espacio mínimo para que quepan horizontalmente */
        justify-content: center;
    }
    .budget-qty-cell .quantity-step-btn {
        display: none !important; /* OCULTAR BOTONES + y - EN MÓVIL */
    }
    .budget-qty-cell .quantity-input-modern {
        width: 75px !important; /* Ajustado para caber en la nueva columna 4 de 85px */
        min-width: 75px !important;
        font-size: 0.75rem;
        padding: 4px 6px;
    }
    .catalog-ribbon {
        gap: 8px; /* Reduce espacios internos */
    }
    main.budget {
        overflow-x: auto; /* Habilitamos el scroll horizontal para la tabla de presupuesto */
    }
}